#kobold training grounds
from eventAPI import *
from APIUtils import *

bwkobolds=0

def fireEvent(e):
   global bwkobolds
   bwkobolds = getTag(e, "bwkobolds")
   if (bwkobolds == 1):
      return 1
   else:
      showMessage(e, ["You stumble upon kobold millitary training grounds. The kobold commander smiles and then speaks to his troops. Now we can test our metal them! The kobold army attacks!"], optionInput)
   fightThem(e)
   if (bwkobolds == 1):
      return 1
   else:
      return 0

def fightThem(e):
   combatRet = combat(e, [("Kobold", 88, 0, 20)])
   if (combatRet == 1):
      wonFight(e)
   elif (combatRet == 3):
      lostFight(e)
   else:
      ranAwayFight(e)

def wonFight(e):
   global bwkobolds
   showMessage(e, ["Piles of kobolds now lay dead and are strewn accross the floor, blood everywhere. You wonder if you'll have nightmares about vicious kobolds in your sleep."])
   bwkobolds = 1
   setTag(e, "bwkobolds", bwkobolds)

def lostFight(e):
   showMessage(e, ["The kobold commander commends his troops for a battle well faught. Too bad for you."])

def ranAwayFight(e):
   global bwkobolds
   showMessage(e, ["You think it wise to get the hell out of there ASAP, and dart out the door."])
   bwkobolds = 0
   setTag(e, "bwkobolds", bwkobolds)
   setExit(e, "maps/bwquadrant1.cfg", 23, 26, 0)