%Leons Petrazickis
%Events Generator

var sn : int := 20
var answer : string (1)
var number : int := 10

put "Welcome to the Setup Program for Fictional Americas."
put "    -Answer in lowercase and do not follow with an [Enter]"
put "    -Run it again whenever needed"
put "    -If it summons aliens from Alpha Centauri, it is not my fault"
put ""

open : sn, "events.txt", put

procedure createunit (owner, unit, veteran, homecity, loc : string)
    put : sn, "CreateUnit"
    put : sn, "owner=", owner
    put : sn, "unit=", unit
    put : sn, "veteran=", veteran
    put : sn, "homecity=", homecity
    put : sn, "locations"
    put : sn, loc
    put : sn, "endlocations"
end createunit

procedure unitkilled (unit, attacker, defender : string)
    put : sn, "UnitKilled"
    put : sn, "unit=", unit
    put : sn, "attacker=", attacker
    put : sn, "defender=", defender
end unitkilled

procedure randomturn (denominator : int)
    put : sn, "RandomTurn"
    put : sn, "denominator=", denominator
end randomturn

procedure negotiation (talker, talkertype, listener, listenertype : string)
    put : sn, "Negotiation"
    put : sn, "talker=", talker
    put : sn, "talkertype=", talkertype
    put : sn, "listener=", listener
    put : sn, "listenertype=", listenertype
end negotiation

procedure text (alphanumeric : string)
    put : sn, "Text"
    put : sn, alphanumeric
    put : sn, "EndText"
end text


put : sn, "@BEGINEVENTS"

put : sn, "@IF\nNOSCHISM\ndefender=ANYBODY\n@THEN\n@ENDIF"

put : sn, "@IF"
negotiation ("Anybody", "humanorcomputer", "Natives", "humanorcomputer")
put : sn, "@THEN"
put : sn, "@ENDIF"

put : sn, "@IF"
negotiation ("Natives", "humanorcomputer", "Anybody", "humanorcomputer")
put : sn, "@THEN"
put : sn, "@ENDIF"

put "Are Vikings being played by a human? (y or n) " ..
getch (answer)
put ""
if answer = "n" then
    for x : 1 .. number
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Vikings", "Hirdmenn", "No", "NONE", "68,4")
        put : sn, "justonce\n@ENDIF"
    end for
    put : sn, "@IF"
    randomturn (6)
    put : sn, "@THEN"
    createunit ("Vikings", "Settlers", "No", "NONE", "68,4")
    put : sn, "@ENDIF"
end if

put "Are Irish being played by a human? (y or n) " ..
getch (answer)
put ""
if answer = "n" then
    for x : 1 .. number
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Irish", "Knight", "No", "NONE", "66,22")
        put : sn, "justonce\n@ENDIF"
    end for
    put : sn, "@IF"
    randomturn (6)
    put : sn, "@THEN"
    createunit ("Irish", "Settlers", "No", "NONE", "66,22")
    put : sn, "@ENDIF"
end if

put "Are Romans being played by a human? (y or n) " ..
getch (answer)
put ""
if answer = "n" then
    for x : 1 .. number
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Romans", "Legion", "No", "NONE", "56,44")
        put : sn, "justonce\n@ENDIF"
    end for
    put : sn, "@IF"
    randomturn (6)
    put : sn, "@THEN"
    createunit ("Romans", "Settlers", "No", "NONE", "56,44")
    put : sn, "@ENDIF"
end if

put "Are Phoenicians being played by a human? (y or n) " ..
getch (answer)
put ""
if answer = "n" then
    for x : 1 .. number div 2
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Phoenicians", "War Elephant", "No", "NONE", "79,77")
        put : sn, "justonce\n@ENDIF"
    end for
    for x : 1 .. number div 2
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Phoenicians", "Eleph. Escort", "No", "NONE", "79,77")
        put : sn, "justonce\n@ENDIF"
    end for
    put : sn, "@IF"
    randomturn (12)
    put : sn, "@THEN"
    createunit ("Phoenicians", "Slaves", "No", "NONE", "79,77")
    put : sn, "@ENDIF"
end if

put "Are Chinese being played by a human? (y or n) " ..
getch (answer)
put ""
if answer = "n" then
    for x : 1 .. number div 2
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Chinese", "Chu Ko Nu", "No", "NONE", "4,12")
        put : sn, "justonce\n@ENDIF"
    end for
    for x : 1 .. number div 2
        put : sn, "@IF"
        randomturn (1)
        put : sn, "@THEN"
        createunit ("Chinese", "Feudal Lord", "No", "NONE", "4,12")
        put : sn, "justonce\n@ENDIF"
    end for
    put : sn, "@IF"
    unitkilled ("Slaves", "Chinese", "Anybody")
    put : sn, "@THEN"
    createunit ("Chinese", "Slaves", "No", "NONE", "4,12")
    put : sn, "@ENDIF"
end if


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put : sn, "@IF"
unitkilled ("Settlers", "Vikings", "Anybody")
put : sn, "@THEN"
createunit ("Vikings", "Slaves", "No", "NONE", "68,4")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Slaves", "Vikings", "Anybody")
put : sn, "@THEN"
createunit ("Vikings", "Slaves", "No", "NONE", "68,4")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Settlers", "Irish", "Anybody")
put : sn, "@THEN"
createunit ("Irish", "Slaves", "No", "NONE", "66,22")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Slaves", "Irish", "Anybody")
put : sn, "@THEN"
createunit ("Irish", "Slaves", "No", "NONE", "66,22")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Settlers", "Romans", "Anybody")
put : sn, "@THEN"
createunit ("Romans", "Slaves", "No", "NONE", "56,44")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Slaves", "Romans", "Anybody")
put : sn, "@THEN"
createunit ("Romans", "Slaves", "No", "NONE", "56,44")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Settlers", "Phoenicians", "Anybody")
put : sn, "@THEN"
createunit ("Phoenicians", "Slaves", "No", "NONE", "79,77")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Slaves", "Phoenicians", "Anybody")
put : sn, "@THEN"
createunit ("Phoenicians", "Slaves", "No", "NONE", "79,77")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Settlers", "Chinese", "Anybody")
put : sn, "@THEN"
createunit ("Chinese", "Slaves", "No", "NONE", "4,12")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("Slaves", "Chinese", "Anybody")
put : sn, "@THEN"
createunit ("Chinese", "Slaves", "No", "NONE", "4,12")
put : sn, "@ENDIF"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put : sn, "@IF"
randomturn (12)
put : sn, "@THEN"
createunit ("Vikings", "Slaves", "No", "NONE", "68,4")
put : sn, "@ENDIF"
put : sn, "@IF"
randomturn (12)
put : sn, "@THEN"
createunit ("Irish", "Slaves", "No", "NONE", "66,22")
put : sn, "@ENDIF"
put : sn, "@IF"
randomturn (12)
put : sn, "@THEN"
createunit ("Romans", "Slaves", "No", "NONE", "56,44")
put : sn, "@ENDIF"
put : sn, "@IF"
randomturn (12)
put : sn, "@THEN"
createunit ("Phoenicians", "Slaves", "No", "NONE", "79,77")
put : sn, "@ENDIF"
put : sn, "@IF"
randomturn (12)
put : sn, "@THEN"
createunit ("Chinese", "Slaves", "No", "NONE", "4,12")
put : sn, "@ENDIF"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put : sn, "@IF"
unitkilled ("V. King", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Vikings", "V. King", "No", "NONE", "66,2\n78,6")
text ("The Viking King has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("I. King", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Irish", "I. King", "No", "NONE", "66,18\n77,9")
text ("The Irish King has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("R. Emperor", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Romans", "R. Emperor", "No", "NONE", "59,45\n65,57")
text ("The Roman Emperor has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("P. Emperor", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Phoenicians", "P. Emperor", "No", "NONE", "83,77\n75,63")
text ("The Phoenician Emperor has fallen and a new one has taken his place.")

put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("C. Emperor", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Chinese", "C. Emperor", "No", "NONE", "6,8\n4,0")
text ("The Chinese Emperor has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("A. Emperor", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Meso-Americans", "A. Emperor", "No", "NONE", "29,57\n34,64")
text ("The Aztec Emperor has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("M. Queen", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Meso-Americans", "M. Queen", "No", "NONE", "48,62\n54,70")
text ("The Mayan Queen has fallen and a new one has taken her place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("I. Emperor", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Meso-Americans", "I. Emperor", "No", "NONE", "71,97\n82,108")
text ("The Incan Emperor has fallen and a new one has taken his place.")
put : sn, "@ENDIF"
put : sn, "@IF"
unitkilled ("N. Queen", "Anybody", "Anybody")
put : sn, "@THEN"
createunit ("Natives", "N. Queen", "No", "NONE", "35,35\n32,44")
text ("The Native Queen has fallen and a new one has taken her place.")
put : sn, "@ENDIF"



put : sn, "@ENDEVENTS"
close : sn

