## Math War (game)

Just BASIC Games
TyCamden
Posts: 42
Joined: Tue Apr 28, 2009 6:20 am

### Math War (game)

Here is the code to my new game: Math War.

It takes numbers and turns them into combat forces, then battles them out.

(from the board: http://justbasic.conforums.com/index.cg ... 1428341995 )

Code:

Code: Select all

``````' math war
'
' in forces\$ the following applies:
' 0 soldiers (they get combined into " 1 ")
' 1 soldiers
' 2 anti-tank soldiers
' 3 anti-aircraft gun
' 4 tanks
' 5 fighters
' 6 bombers
' 7 submarine
' 8 battleship
' 9 carrier (+2 fighters to combat)
' this data is then converted into use by the array...
' ForcCount(y,z)

cls
dim p(2), stat(2,10), ForcCount(2,1), desc\$(10)
dim OwedSubs(2,1), OwedFighters(2,1), OwedCarriers(2,1)

gosub [setVariables]
gosub [getOptions] ' mode & zones
gosub [introScreen]

gosub [combat]

print
print "Game over."
print
print

end

[combat]
for x = 1 to zones
print
gosub [press]
print "Zone: ";x
for y=1 to  2
print "Opponent: ";y
temp = INT((x/p(y))*1000000000000)
forces\$ = str\$(temp)
[checkForcesLen]
z=len(forces\$)
select case
case z<ForcesDigits
forces\$ = "0" + forces\$
goto [checkForcesLen]
case z>ForcesDigits
forces\$ = left\$(forces\$,ForcesDigits )
case z=ForcesDigits
' ok
end select
'            print forces\$ ' this was used during debugging
for z = 1 to 10
ForcCount(y,z) = 0
next z
for z = 1 to ForcesDigits
xx\$ = mid\$(forces\$,z,1)
tempType = val(xx\$)
ForcCount(y,tempType) = ForcCount(y,tempType) + 1
next z
' combine the Zero soldiers into the One soldiers
if ForcCount(y,0) > 0 then
ForcCount(y,1) = ForcCount(y,1) + ForcCount(y,0)
ForcCount(y,0) = 0
end if
' add bonue planes for carriers
if ForcCount(y,9) > 0 then
ForcCount(y,5) = ForcCount(y,5) + (2 * ForcCount(y,9))
end if
gosub [displayForces]

print
next y
'
'   forces are distributed and ready for battle

'            1 soldiers
'            2 anti-tank soldiers
'            3 anti-aircraft gun
'            4 tanks
'            5 fighters
'            6 bombers
'            7 submarine
'            8 battleship
'            9 carrier (+2 fighters to combat)

zoneRunthrough = 0 ' number of times through the loop within a zone

[startZoneBattleRound]
zoneRunthrough = zoneRunthrough + 1
anyoneFiredInZoneInRound = 0

' sub sneak attack on random enemy naval vessel. if it destroys carrier then
'       enemy loses 2 fighters (with no retaliation with exception
'      for subs destroyed in this way)
subShot(1) = ForcCount(1,7)
subShot(2) = ForcCount(2,7)
' in forces\$ the following applies:
' 7 submarine
anySubsFiredFlag = 0
for ssc = 1 to 2
[takeASubShot]
if subShot(ssc) > 0 then ' opponent #scc has subshots to take
opptot = ForcCount(topp(ssc),7) + ForcCount(topp(ssc),8) + ForcCount(topp(ssc),9)
' in forces\$ the following applies:
' 7 submarine
' 8 battleship
' 9 carrier (+2 fighters to combat)
if opptot > 0 then ' opponent #scc has naval targets
target=int(rnd(1)*3) + 7 ' 7 to 9
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anySubsFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Sub to destroy "; desc\$(target)
if zoneRunthrough < 2 then
if target = 9 then
ForcCount(topp(ssc),5) = ForcCount(topp(ssc),5) - 2
print "   Two planes on carrier deck also destroyed."
end if
end if
subShot(ssc) = subShot(ssc) - 1
end if
goto [takeASubShot]
else
'ok
end if
end if
next ssc

if mode=1 then
if anySubsFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' Each AA Gun destroys an aircraft without retaliation
'
anyAAFiredFlag = 0
for ssc = 1 to 2
if ForcCount(ssc,3) > 0 then ' opponent #scc has AA Gun
' in forces\$ the following applies:
' 3 anti-aircraft gun
opptot = ForcCount(topp(ssc),5) + ForcCount(topp(ssc),6)
' in forces\$ the following applies:
' 5 fighters
' 6 bombers
for aashots = 1 to ForcCount(ssc,3) ' each gun gets a shot
if opptot > 0 then ' there are aircraft targets
target = int(rnd(1)*2)+5 ' 5 or 6
if ForcCount(topp(ssc),target) < 1 then
if target = 5 then
target = 6
else ' target = 6
target = 5
end if
end if
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
opptot = opptot - 1
anyAAFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses AA Gun to destroy "; desc\$(target)
end if
next aashots
end if
next ssc

if mode=1 then
if anyAAFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' Fighters kill air units (bombers get no retaliation)
'
FighterShot(1) = ForcCount(1,5)
FighterShot(2) = ForcCount(2,5)
' in forces\$ the following applies:
' 5 fighters
anyFightersFiredFlag = 0
for ssc = 1 to 2
[takeAFighterShot]
if FighterShot(ssc) > 0 then ' opponent #scc has fighter-shots to take
opptot = ForcCount(topp(ssc),5) + ForcCount(topp(ssc),6)
' in forces\$ the following applies:
' 5 fighters
' 6 bombers
if opptot > 0 then ' opponent #scc has air targets
target=int(rnd(1)*2) + 5 ' 5 to 6
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyFightersFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Fighter to destroy "; desc\$(target)
FighterShot(ssc) = FighterShot(ssc) - 1
end if
goto [takeAFighterShot]
else
'ok
end if
end if
next ssc

if mode=1 then
if anyFightersFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' battleships attack now with the following priorities:
'
' 1.) other battleships
' 2.) other carriers
' 3.) battleship kills 1 random air unit (with no retaliation)
' 4.) battleship kills 1 random ground unit (with no retaliation)
'
BshipShot(1) = ForcCount(1,8)
BshipShot(2) = ForcCount(2,8)
' in forces\$ the following applies:
' 8 battleship
anyBshipFiredFlag = 0
for ssc = 1 to 2

[takeABshipShotagainstBship]
if BshipShot(ssc) > 0 then ' opponent #scc has Battleship-shots to take
opptot = ForcCount(topp(ssc),8)
if opptot > 0 then ' opponent #scc has Bship targets
'                    target=int(rnd(1)*2) + 5 ' 5 to 6
target = 8
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyBshipFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Battleship to destroy "; desc\$(target)
BshipShot(ssc) = BshipShot(ssc) - 1
end if
goto [takeABshipShotagainstBship]
else
'ok
end if
end if

[takeABshipShotagainstCarrier]
if BshipShot(ssc) > 0 then ' opponent #scc has Battleship-shots to take
opptot = ForcCount(topp(ssc),9)
' in forces\$ the following applies:
' 9 carrier (+2 fighters to combat)
if opptot > 0 then ' opponent #scc has Carrier targets
'                    target=int(rnd(1)*2) + 5 ' 5 to 6
target = 9
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyBshipFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Battleship to destroy "; desc\$(target)
' Note here that planes on carrier were already launched and
'  potentially already in battle, so sinking carrier will not destroy them
'  unlike the round-1 Sub sneak attack, which could do so.
BshipShot(ssc) = BshipShot(ssc) - 1
end if
goto [takeABshipShotagainstCarrier]
else
'ok
end if
end if

[takeABshipShotagainstAir]
if BshipShot(ssc) > 0 then ' opponent #scc has Battleship-shots to take
opptot = ForcCount(topp(ssc),5) + ForcCount(topp(ssc),6)
' in forces\$ the following applies:
' 5 fighters
' 6 bombers
if opptot > 0 then ' opponent #scc has air targets
target=int(rnd(1)*2) + 5 ' 5 to 6
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyBshipFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Battleship to destroy "; desc\$(target)
BshipShot(ssc) = BshipShot(ssc) - 1
end if
goto [takeABshipShotagainstAir]
else
'ok
end if
end if

[takeABshipShotagainstGround]
if BshipShot(ssc) > 0 then ' opponent #scc has Battleship-shots to take
opptot = ForcCount(topp(ssc),1) + ForcCount(topp(ssc),2) + ForcCount(topp(ssc),3) + ForcCount(topp(ssc),4)
' in forces\$ the following applies:
' 1 soldiers
' 2 anti-tank soldiers
' 3 anti-aircraft gun
' 4 tanks
if opptot > 0 then ' opponent #scc has ground targets
target=int(rnd(1)*4) + 1 ' 1 to 4
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyBshipFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Battleship to destroy "; desc\$(target)
BshipShot(ssc) = BshipShot(ssc) - 1
end if
goto [takeABshipShotagainstGround]
else
'ok
end if
end if

next ssc

if mode=1 then
if anyBshipFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' bombers kill 2 ! (TWO)  random ground unit (with no retaliation)
'
BomberShot(1) = ForcCount(1,6) * 2
BomberShot(2) = ForcCount(2,6) * 2
' in forces\$ the following applies:
' 6 bombers
anyBombersFiredFlag = 0
for ssc = 1 to 2
[takeABomberShot]
if BomberShot(ssc) > 0 then ' opponent #scc has Bomber-shots to take
opptot = ForcCount(topp(ssc),1) + ForcCount(topp(ssc),2) + ForcCount(topp(ssc),3) + ForcCount(topp(ssc),4)
' in forces\$ the following applies:
' 1 soldiers
' 2 anti-tank soldiers
' 3 anti-aircraft gun
' 4 tanks
if opptot > 0 then ' opponent #scc has ground targets
target=int(rnd(1)*4) + 1 ' 1 to 4
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyBombersFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Bomber to destroy "; desc\$(target)
BomberShot(ssc) = BomberShot(ssc) - 1
end if
goto [takeABomberShot]
else
'ok
end if
end if
next ssc

if mode=1 then
if anyBombersFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' each anti-tank soldiers kills 2 tanks
'
ATS(1) = ForcCount(1,2) * 2
ATS(2) = ForcCount(2,2) * 2
' in forces\$ the following applies:
' 2 anti-tank soldiers
anyATSFiredFlag = 0
for ssc = 1 to 2
[takeAnATSShot]
if ATS(ssc) > 0 then ' opponent #scc has Anti-tank-soldier-shots to take
opptot = ForcCount(topp(ssc),4)
' in forces\$ the following applies:
' 4 tanks
if opptot > 0 then ' opponent #scc has tank targets
'                    target=int(rnd(1)*4) + 1 ' 1 to 4
target = 4
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyATSFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses anti-tank soldier to destroy "; desc\$(target)
ATS(ssc) = ATS(ssc) - 1
end if
goto [takeAnATSShot]
else
'ok
end if
end if
next ssc

if mode=1 then
if anyATSFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if
'
' each tank kills 2 ! (TWO) ground units
'
TankShot(1) = ForcCount(1,4) * 2
TankShot(2) = ForcCount(2,4) * 2
' in forces\$ the following applies:
' 4 tanks
anyTankFiredFlag = 0
for ssc = 1 to 2
[takeAtankShot]
if TankShot(ssc) > 0 then ' opponent #scc has Bomber-shots to take
opptot = ForcCount(topp(ssc),1) + ForcCount(topp(ssc),2) + ForcCount(topp(ssc),3) + ForcCount(topp(ssc),4)
' in forces\$ the following applies:
' 1 soldiers
' 2 anti-tank soldiers
' 3 anti-aircraft gun
' 4 tanks
if opptot > 0 then ' opponent #scc has ground targets
target=int(rnd(1)*4) + 1 ' 1 to 4
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anyTankFiredFlag  = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses tank to destroy "; desc\$(target)
TankShot(ssc) = TankShot(ssc) - 1
end if
goto [takeAtankShot]
else
'ok
end if
end if
next ssc

if mode=1 then
if anyTankFiredFlag = 1 then
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]
end if
end if

'
' each soldier kills either a soldier or an anti-tank soldier
'
SoldShot(1) = ForcCount(1,1)
SoldShot(2) = ForcCount(2,1)
' in forces\$ the following applies:
' 1 soldiers
anySoldFiredFlag = 0
for ssc = 1 to 2
[takeASoldShot]
if SoldShot(ssc) > 0 then ' opponent #scc has Soldier-shots to take
opptot = ForcCount(topp(ssc),1) + ForcCount(topp(ssc),2)
' in forces\$ the following applies:
' 1 soldiers
' 2 anti-tank soldiers
if opptot > 0 then ' opponent #scc has Soldier targets
target=int(rnd(1)*2) + 1 ' 1 to 2
if ForcCount(topp(ssc),target) > 0 then
ForcCount(topp(ssc),target) = ForcCount(topp(ssc),target) - 1
anySoldFiredFlag = 1
anyoneFiredInZoneInRound = 1
print "Opponent ";ssc;" uses Soldier to destroy "; desc\$(target)
SoldShot(ssc) = SoldShot(ssc) - 1
end if
goto [takeASoldShot]
else
'ok
end if
end if
next ssc

if anyoneFiredInZoneInRound = 1 then
print
goto [startZoneBattleRound]
end if

' everything should have destroyed each other in main combat before
'   program starts to check on these other scenarios

[startPostZBRound]
anyoneFiredInZoneInRound = 0

' Anti-Tank Soldiers (if any) try to kill each other.
for ssc = 1 to 2
if ForcCount(ssc,2) > 0 then
' 2 anti-tank soldiers
if ForcCount(topp(ssc),2) > 0 then
' both opponents have Anti-Tank Soldiers
if ForcCount(ssc,2) < ForcCount(topp(ssc),2) then
for pzcX = 1 to ForcCount(topp(ssc),2)
print "Both opponents lost an Anti-Tank Soldier in battle to each-other."
ForcCount(ssc,2) = ForcCount(ssc,2) - 1
ForcCount(topp(ssc),2) = ForcCount(topp(ssc),2) - 1
anyoneFiredInZoneInRound = 1
next pzcX
else
for pzcX = 1 to ForcCount(ssc,2)
print "Both opponents lost an Anti-Tank Soldier in battle to each-other."
ForcCount(ssc,2) = ForcCount(ssc,2) - 1
ForcCount(topp(ssc),2) = ForcCount(topp(ssc),2) - 1
anyoneFiredInZoneInRound = 1
next pzcX
end if
else
' opponent ssc HAS Anti-Tank Soldiers BUT other opponent does NOT
end if
else
' opponent ssc does NOT have Anti-Tank Soldiers
end if
next ssc

' See if one player has AA Guns (with no supporting ground forces), and the other has any ground forces...
'   if so then the ground units destroy the AA Guns
for ssc = 1 to 2
if ForcCount(ssc,3) > 0 then
' 3 anti-aircraft gun
'
' make sure that player ssc has no supporting ground troops
' 1 soldiers
' 2 anti-tank soldiers
' 3 anti-aircraft gun
' 4 tanks
otherCheckFlagX = 0
for tempX = 1 to 4
if tempX <> 3 then
otherCheckFlagX = otherCheckFlagX + ForcCount(ssc,tempX)
end if
next tempX
if  otherCheckFlagX = 0 then ' player player ssc has no supporting ground troops
' next make sure that opponent of scc has ground forces
otherCheckFlagX = 0
otherCheckFlagY = 0
for tempX = 1 to 4
if tempX <>3 then
otherCheckFlagX = otherCheckFlagX + ForcCount(topp(ssc),tempX)
otherCheckFlagY = tempX
end if
next tempX
if otherCheckFlagX > 0 then
for tempX = 1 to ForcCount(ssc,3)
print "Opponent ";topp(ssc); "uses ";desc\$(otherCheckFlagY);
print " to destroy an AA Gun."
ForcCount(ssc,3) = ForcCount(ssc,3) - 1
anyoneFiredInZoneInRound = 1
next tempX
else
' opponent of ssc does NOT have ground forces
'                            print "Opponent of player "; ssc;" does not have ground forces." ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end if
else
' player ssc has units other than AAGun(s)
end if
end if
next ssc

if anyoneFiredInZoneInRound = 1 then
print
goto [startPostZBRound]
end if

' At this point, noone has fired in last round (runtrough)...

' if one player has No forces, then SKIP the following withdrawal sections and get right to winner
gosub [CheckForNoForces]
' results will have...
' FVOps = the number of opponents with no forces
' FVTarget = the opponent with no forces (if only one opponent has no forces)
if FVOps > 0 then
goto [doneRemovingForcesInZone]
end if

' See if one player has Subs and the other No Naval units
'   if so then Subs withdraws
'   the variable OwedSubs(player#,zone#) remembers how many withdrew in all of the zones combined
AnySubWithdraws = 0
for ssc = 1 to 2
if ForcCount(ssc,7) > 0 then ' opponent #scc has Subs
' 7 submarine
opptot = ForcCount(topp(ssc),7) + ForcCount(topp(ssc),8) + ForcCount(topp(ssc),9)
' 7 submarine
' 8 battleship
' 9 carrier (+2 fighters to combat)
if opptot < 1 then ' opponent of scc has no Naval units
print "Opponent ";ssc;" withdraws Subs."
OwedSubs(ssc,x) = OwedSubs(ssc,x) + ForcCount(ssc,7)
ForcCount(ssc,7) = 0
AnySubWithdraws = 1
end if
end if
next ssc
if AnySubWithdraws = 1 then
print
end if

' All remaining Fighter Planes withdraw
'   the variable OwedFighters(player#,zone#) remembers how many withdrew in all of the zones combined
AnyPlaneWithdraws = 0
for ssc = 1 to 2
if ForcCount(ssc,5) > 0 then ' opponent #scc has Fighters
' 5 fighters
print "Opponent ";ssc;" withdraws Fighters."
OwedFighters(ssc,x) = OwedFighters(ssc,x) + ForcCount(ssc,5)
ForcCount(ssc,5) = 0
AnyPlaneWithdraws = 1
end if
next ssc
if AnyPlaneWithdraws = 1 then
print
end if

' See if one player has Carriers and ONLY carriers
'   if so then those Carriers withdraw
'   the variable OwedCarriers(player#,zone#) remembers how many withdrew in all of the zones combined
AnyCarrierWithdraws = 0
for ssc = 1 to 2
if ForcCount(ssc,9) > 0 then ' opponent #scc has Carriers
' 9 carrier

tempForcesFlag = 0
for carrTempX = 1 to 10
if  carrTempX <> 9 then
if ForcCount(ssc,carrTempX) > 0 then
tempForcesFlag = 1
end if
end if
next carrTempX

if tempForcesFlag = 0 then
print "Opponent ";ssc;" withdraws Carriers."
OwedCarriers(ssc,x) = OwedCarriers(ssc,x) + ForcCount(ssc,9)
ForcCount(ssc,9) = 0
AnyCarrierWithdraws = 1
end if
end if
next ssc
if AnyCarrierWithdraws = 1 then
print
end if

[doneRemovingForcesInZone]
' show Remaining Forces in zone in round
print
print "Remaining Forces:"
for y = 1 to 2
print
print "Opponent : ";y
gosub [displayForces]
next y
print
gosub [press]

' before moving to next zone...
'   DISPLAY VICTOR OF BATTLE ZONE
'       to do this, first see how many forces each opponent has
gosub [CheckForNoForces]
' results will have...
' FVOps = the number of opponents with no forces
' FVTarget = the opponent with no forces (if only one opponent has no forces)
select case FVOps
case 2
' ALL opponents have no forces
print "All opponents in zone - Destroyed. Total annihilation has occured."
print
case 1
' ONE opponent has no forces, and it is player # FVTarget
print "Opponent ";topp(FVTarget);" wins the zone."
print
zoneWins(topp(FVTarget)) = zoneWins(topp(FVTarget)) +1
case else ' 0
' NO opponents have no forces
print "No opponent in zone has been destroyed."
print
end select

next x

' check to see if there is a winner of war

if zoneWins(1) >  zoneWins(2) then
print "Opponent 1 wins the War (";zoneWins(1);"zones to ";zoneWins(2);" zones)."
print
end if

if zoneWins(1) =  zoneWins(2) then
print "The War was a tie (";zoneWins(1);" zones each)."
end if

if zoneWins(1) <  zoneWins(2) then
print "Opponent 2 wins the War (";zoneWins(2);"zones to ";zoneWins(1);" zones)."
print
end if

return

[setVariables]
ForcesDigits = 10
redim ForcCount(2,ForcesDigits)
topp(1) = 2
topp(2) = 1
zoneWins(1) = 0
zoneWins(2) = 0
desc\$(0) = "soldier"
desc\$(1) = "soldier"
desc\$(2) = "anti-tank soldier"
desc\$(3) = "anti-aircraft gun"
desc\$(4) = "tank"
desc\$(5) = "fighter plane"
desc\$(6) = "bomber"
desc\$(7) = "submarine"
desc\$(8) = "battleship"
desc\$(9) = "carrier"
return

[getOptions]
print "Math War"
print
print "options"
mode = 0
while mode = 0
[modeInput]
print
print "1) Normal mode"
print "2) Quick mode"
print "3) See Details About Game First"
print
input mode
select case mode
case 1, 2
' ok
case 3
' See Details About Game First
gosub [showDetails]
goto [modeInput]
case else
mode = 0
end select
wend
[getZones]
print
print "Fighting will occur in how many zones ";
input zones
print

zones=INT(zones)
if zones < 1 then
print "There must be at least 1 zone."
goto [getZones]
end if

redim OwedSubs(2,zones)
for owedResetX = 1 to 2
for owedResetY = 1 to zones
OwedSubs(owedResetX,owedResetY) = 0
next owedResetY
next owedResetX

redim OwedFighters(2,zones)
for owedResetX = 1 to 2
for owedResetY = 1 to zones
OwedFighters(owedResetX,owedResetY) = 0
next owedResetY
next owedResetX

redim OwedCarriers(2,zones)
for owedResetX = 1 to 2
for owedResetY = 1 to zones
OwedCarriers(owedResetX,owedResetY) = 0
next owedResetY
next owedResetX

[getOpponents]
print
print "What type of opponents do you want ? "
print
print "1) Random opponent number"
print "2) Manually enter opponent number"
print
input OppNbrType
print

OppNbrType = INT(OppNbrType)
select case OppNbrType
case 1
for x = 1 to 2
'ex of 1-10 random:  int(rnd(1)*10)+1
p(x) = int(rnd(1)*90000)+10000
next x
case 2
for x = 1 to 2
print "Enter opponent number for Opp# ";x
input p(x)
print
p(x) = INT(p(x))
next x
case else
goto [getOpponents]
end select

return

[introScreen]
cls
print "Math War"
print
print "Today's Opponents:"
print
print p(1)
print "vs"
print p(2)
print
return

[showDetails]
print
print "Opponents are created based on math algorythms."
print "This includes the numbers of forces for each opponent."
print "Forces can include:"
for descX = 1 to 9
print desc\$(descX)
next descX
print
print "press enter to continue";
input x\$
print
print "The battles will occur following certain rules:"
print
print "Subs do sneak attack on random enemy naval vessel."
print "If it destroys carrier then enemy loses 2 fighters."
print "Vessels sunk this was get no retaliation, Except for Subs."
print
print "AA guns at bombers & fighters (with no retaliation)"
print
print "press enter to continue";
input x\$
print
print "Fighters kill air units (bombers get no retaliation)"
print
print "Battleship kills 1 random air unit (with no retaliation) AND"
print "battleship kills 1 random ground unit (with no retaliation)."
print
print "Bombers kill 2 ! (TWO) random ground units (with no retaliation)"
print
print "Each anti-tank soldiers kills 2 tanks."
print
print "Each tank kills 2 ground units."
print
print "Each soldier kills either a soldier or an anti-tank soldier."
print
print "press enter to continue";
input x\$
print
print "Anti-Tank Soldiers (if any) try to kill each other."
print
print "Any AA Guns with no supporting ground forces get destroyed by opponent ground forces."
print
print "If one opponent has no forces, then there is a winner for that zone, otherwise..."
print
print "If a player has Subs, but the other has no naval forces, then those Subs withdraw."
print
print "All remaining Fighter Planes withdraw."
print
print "If one player has Carriers and ONLY carriers, they withdraw."
print
return

[press]
if mode=1 then
print "press enter to continue";
input x\$
print
end if
return

[displayForces]
checkOnNone = 1
for z = 0 to 9
if ForcCount(y,z)<>0 then
checkOnNone = 0
print ForcCount(y,z);" "; desc\$(z);
if ForcCount(y,z)>1 then
print "s"
else
print
end if
end if
next z
if checkOnNone = 1 then
print "None."
print
end if
return

[CheckForNoForces]
for VFX = 1 to 2
VictorForcesTotal(VFX) = 0
for VFY = 1 to 10
VictorForcesTotal(VFX) = VictorForcesTotal(VFX) + ForcCount(VFX,VFY)
next  VFY
next VFX
FVOps = 0
for VFX = 1 to 2
if VictorForcesTotal(VFX) = 0 then
FVOps = FVOps + 1
FVTarget = VFX
end if
next VFX
return``````