var name1, name2, choose : string
var money1, money2, buy, income1, income2, attack1, attack2, luck1, luck2 : int
var soldier1, soldier2 : int
begin
money1 := 100
money2 := 100
soldier1 := 0
soldier2 := 0
income1 := 10
income2 := 10
put "Type in player 1's name: " ..
get name1
put "Type in player 2's name: " ..
get name2
put ""
put "War: ", name1, " against ", name2
loop
put name1, "'s turn!"
put "Your income is ", income1, " . You recieve the income."
money1 := money1 + income1
put "You have ", money1, " cash currently, and ", soldier1, " soldiers."
put "How many soldiers will you buy? 1 cash per soldier"
get buy
if buy <= money1
then
money1 := money1 - buy
soldier1 := soldier1 + buy
put "You bought ", buy, " soldiers."
else
put "Not enough money, you buy nothing"
end if
put "Would you like to attack, pillage, or nothing. (type in attack, pillage, or nothing) " ..
get choose
if choose = "attack"
then
randint(luck1, 8, 10)
randint(luck2, 8, 10)
attack1 := luck1 / 10 * soldier1
attack2 := luck2 / 10 * soldier2
if attack1 > attack2
then
put "You succeed in attacking. You win ", round (money2 / 2), " cash."
money1 := round (money1 + (money2 / 2))
money2 := round (money2 / 2)
else
put "You fail the attack. You lose ", round (money1 / 2), " cash."
money1 := round (money1 / 2)
money2 := round (money2 + (money1 / 2))
end if
soldier1 := attack1 - (attack2 / 2)
soldier2 := attack2 - (attack1 / 2)
put "You suffered ", attack2 / 2, " losses, and killed ", attack1 / 2, " soldiers."
end if
cls
put name2, "'s turn!"
put "Your income is ", income2, " . You recieve the income."
money2 := money2 + income2
put "You have ", money2, " cash currently, and ", soldier2, " soldiers."
put "How many soldiers will you buy? 1 cash per soldier"
get buy
if buy <= money2
then
money2 := money2 - buy
soldier2 := soldier2 + buy
put "You bought ", buy, " soldiers."
else
put "Not enough money, you buy nothing"
end if
put "Would you like to attack, pillage, or nothing. (type in attack, pillage, or nothing)" ..
get choose
if choose = "attack"
then
randint(luck1, 8, 10)
randint(luck2, 8, 10)
attack1 := luck1 / 10 * soldier1
attack2 := luck2 / 10 * soldier2
if attack2 > attack1
then
put "You succeed in attacking. You win ", round (money1 / 2), " cash."
money2 := round (money2 + (money1 / 2))
money1 := round (money1 / 2)
else
put "You fail the attack. You lose ", round (money2 / 2), " cash."
money2 := round (money2 / 2)
money1 := round (money1 + (money2 / 2))
end if
soldier1 := attack1 - (attack2 / 2)
soldier2 := attack2 - (attack1 / 2)
put "You suffered ", attack1 / 2, " losses, and killed ", attack2 / 2, " soldiers."
end if
cls
end loop
end
|