#Defense of the Gates of Rennibister
from eventAPI import *
from APIUtils import *

rtDefendFlag2=0

def fireEvent(e):
   global rtDefendFlag2
   rtDefendFlag2 = getTag(e, "rtDefendFlag2")
   if (rtDefendFlag2 == 1):
      returnVisit(e)
   else:
      firstVisit(e)

def firstVisit(e):
   global rtDefendFlag2
   setTag(e, "rtDefendFight1", 0)
   setTag(e, "rtDefendFight2", 0)
   setTag(e, "rtDefendFight3", 0)
   setTag(e, "rtDefendFight4", 0)
   setTag(e, "rtDefendFight5", 0)
   setTag(e, "rtDefendFight7", 0)
   setTag(e, "rtDefendmessage1", 0)
   setTag(e, "rtDefendmessage2", 0)
   showMessage(e, ["You follow the Captain out to the gates of Rennibister."])
   showPicture(e, "Guard_of_Rennibister")
   showMessage(e, ["\"Goblins approaching sir!\""])
   showPicture(e, "Human_Male06")
   showMessage(e, ["\"Get more men up on that wall! I need archers moved to the high rampart!\""])
   showPicture(e, "Guard_of_Rennibister")
   showMessage(e, ["\"Four or perhaps five hundred outside now, sir! They have taken time to create a battering ram!\""])
   showPicture(e, "Human_Male06")
   showMessage(e, ["\"Goblins usually do not bother with siege engines.\"", "", "\"Watch out for orcs to be leading them.\""])
   showMessage(e, ["\"Brace those gates!\""])
   showPicture(e, "Guard_of_Rennibister")
   showMessage(e, ["\"Sir! Watch reports kobold sappers at the western wall!\""])
   showPicture(e, "Human_Male06")
   showMessage(e, ["\"Damn it all! Send a squad to the western wall to try and flush them out!\""])
   showMessage(e, ["No sooner has the captain spoken these words than a great cloud of smoke rises from the western end of the city."])
   showMessage(e, ["\"The wall appears to have been breached already.\"", "", "Turning towards you, the captain gives you an appraising look."])
   showMessage(e, ["\"We need men to secure the city from any intruders. Go to the western wall. Find and help to secure any breach of the defenses. If this cannot be done then their sappers will cut us from behind and open the gates.\""])
   rtDefendFlag2=1
   setTag(e, "rtDefendFlag2", rtDefendFlag2)


def returnVisit(e):
   clearPicture(e)
   showMessage(e, ["Men press themselves against the gates as a resounding thud shakes the entire wall. It will only be a matter of time before the gates are broken and the goblin army enters the city."])
   showPicture(e, "Human_Male06")
   showMessage(e, ["\"Go, damn you! Secure the city!\""])
