Пример #1
0
 def _board_hie(fieldBoardLines):
     hieDecision = ArabolyRandom(max=3, min=1)
     if hieDecision == 1:
         fieldBoardLines.reverse()
     elif hieDecision == 2:
         for lineNum in range(len(fieldBoardLines)):
             newLine = fieldBoardLines[lineNum]
             for match in re.finditer("[a-zA-Z]{2,}", newLine):
                 newString = "G" + ("R" * (len(match.group(0)) - 1))
                 newLine = newLine[:match.start(
                 )] + newString + newLine[match.end():]
             fieldBoardLines[lineNum] = newLine
     elif hieDecision == 3:
         for lineNum in range(len(fieldBoardLines)):
             newLine = fieldBoardLines[lineNum]
             for match in re.finditer(
                     "\u0003(1[0-5]|0?[0-9]),(1[0-5]|0?[0-9])", newLine):
                 if len(match.group(1)) == 1:
                     newColours = "\u0003" + str(ArabolyRandom(max=9,
                                                               min=0))
                 elif len(match.group(1)) == 2:
                     newColours = "\u0003{:02d}".format(
                         ArabolyRandom(max=15, min=0))
                 if len(match.group(2)) == 1:
                     newColours += "," + str(ArabolyRandom(max=9, min=0))
                 elif len(match.group(2)) == 2:
                     newColours += ",{:02d}".format(
                         ArabolyRandom(max=15, min=0))
                 newLine = newLine[:match.start(
                 )] + newColours + newLine[match.end():]
             fieldBoardLines[lineNum] = newLine
     return fieldBoardLines
Пример #2
0
 def _land_chance(args, channel, context, output, src, srcField, srcFull, srcPlayer, status):
     if len(args):
         if ArabolyGenerals._authorised(channel, context, srcFull)   \
         or context.clientParams["testing"]:
             randsFromArgs = True
         else:
             status = False
             return context, output, srcField, srcPlayer, status
     else:
         randsFromArgs = False
     for kadeLine in context.kades[ArabolyRandom(limit=len(context.kades))]:
         output = ArabolyGenerals._push_output(channel, context, output, kadeLine.rstrip("\n"), outputLevel=ArabolyOutputLevel.LEVEL_GRAPHICS)
     output = ArabolyGenerals._push_output(channel, context, output, "Kade thinks!", delay=1)
     output = ArabolyGenerals._push_output(channel, context, output, "Kade is thinking!", delay=2)
     srcPlayer = context.players["byName"][src]
     kadecision = ArabolyRandom(max=5, min=1) if not randsFromArgs else int(args[0])
     if context.clientParams["recording"]:
         context.clientParams["recordingXxxLastArgs"] += [kadecision]
     if kadecision == 1:
         context, output, srcPlayer = ArabolyFields._land_chance_bank(args, channel, context, output, randsFromArgs, src, srcPlayer)
     elif kadecision == 2:
         context, output, srcPlayer = ArabolyFields._land_chance_mortgage(args, channel, context, output, randsFromArgs, src, srcPlayer)
     elif kadecision == 3:
         context, output, srcPlayer = ArabolyFields._land_chance_swap(args, channel, context, output, randsFromArgs, src, srcPlayer)
     elif kadecision == 4:
         context, output, srcPlayer = ArabolyFields._land_chance_redist(args, channel, context, output, randsFromArgs, src, srcPlayer)
     else:
         output = ArabolyGenerals._push_output(channel, context, output, "Hm! Kade feels stupid!", delay=3)
     return context, output, srcField, srcPlayer, status
Пример #3
0
 def dispatch_dice(args, channel, context, output, src, srcFull, status):
     if context.players["numMap"][context.players["curNum"]] != src:
         status = False
     elif len(args):
         if  len(args) >= 2                                          \
         and ArabolyGenerals._authorised(channel, context, srcFull)  \
         or  context.clientParams["testing"]:
             dice = [int(args[0]), int(args[1])]
         else:
             status = False
     else:
         dice = [ArabolyRandom(max=6, min=1), ArabolyRandom(max=6, min=1)]
     if status:
         if context.clientParams["recording"]:
             context.clientParams["recordingXxxLastArgs"] = dice
         channel, context, src, output = ArabolyTrade._leave(
             channel, context, src, output)
         output = ArabolyGenerals._push_output(
             channel, context, output,
             "{src} rolls {dice[0]} and {dice[1]}!".format(**locals()))
         srcPlayer = context.players["byName"][src]
         srcField = context.board[srcPlayer["field"]]
         if "loonyBinTurns" in srcPlayer:
             context, output, srcPlayer = ArabolyGameMode._dice_loony_bin(
                 channel, context, dice, output, src, srcPlayer)
         else:
             srcField = context.board[(srcPlayer["field"] + dice[0] +
                                       dice[1]) % len(context.board)]
             srcFieldPastGo = srcField["field"] < srcPlayer["field"]
             srcPlayer["field"] = srcField["field"]
             output = ArabolyGenerals._board(channel, context, output, src)
             if dice[0] == dice[1]:
                 context, output, srcField, srcPlayer, status = ArabolyGameMode._dice_doubles(
                     args, channel, context, dice, output, src, srcField,
                     srcFieldPastGo, srcFull, srcPlayer, status)
             else:
                 if "doubles" in srcPlayer:
                     del srcPlayer["doubles"]
                 context, output, srcField, srcPlayer, status = ArabolyFields._land_field(
                     args[2:], channel, context, output, src, srcField,
                     srcFieldPastGo, srcFull, srcPlayer, status)
         if context.state == ArabolyGameState.GAME:
             if srcPlayer["wallet"] <= 0:
                 context, output = ArabolyBankruptcyMode._enter(
                     channel, context, output, src, srcPlayer)
             if  context.state == ArabolyGameState.GAME              \
             and len([n for n in context.players["numMap"] if n != None]) > 1:
                 context, output = ArabolyGenerals._next_player(
                     channel, context, output, src)
     return args, channel, context, output, src, srcFull, status
Пример #4
0
 def _land_chrono(channel, context, output, src, srcField, srcPlayer):
     if srcField["owner"] == -1:
         context, output = ArabolyPropertyMode._enter(channel, context, output, src, srcField, srcPlayer)
     elif srcField["owner"] != -1    \
     and  srcField["owner"] != src:
         if srcField["mortgaged"]:
             output = ArabolyGenerals._push_output(channel, context, output, "Oops! {srcField[owner]} cannot collect rent on {srcField[title]} as it is mortgaged!".format(**locals()))
         else:
             otherChronos = 0
             for srcPropNum in context.players["byName"][srcField["owner"]]["properties"]:
                 srcProp = context.board[srcPropNum]
                 if srcProp["type"] == ArabolyGameField.CHRONO:
                     otherChronos += 1
             srcPropRent = srcField["strings"][ArabolyStringType.RENT][otherChronos][0]
             if srcField["level"] == 1:
                 srcPropRent *= 2
             if context.players["difficulty"] == "hard":
                 srcPropRent *= 2
             for rentString in srcField["strings"][ArabolyStringType.LAND][srcField["level"]]:
                 rands = [ArabolyRandom(limit=150-5, min=5) for x in range(10)]
                 if len(srcField["strings"][ArabolyStringType.LAND][srcField["level"]]) < 10:
                     output = ArabolyGenerals._push_output(channel, context, output, rentString.format(cost=srcPropRent, owner=srcField["owner"], prop=srcField["title"], rands=rands, who=src))
                 else:
                     output = ArabolyGenerals._push_output(channel, context, output, rentString.format(cost=srcPropRent, owner=srcField["owner"], prop=srcField["title"], rands=rands, who=src), delay=0)
             context.players["byName"][srcField["owner"]]["wallet"] += srcPropRent
             srcPlayer["wallet"] -= srcPropRent
     return context, output, srcField, srcPlayer
Пример #5
0
 def _land_free_lsd(channel, context, output, src, srcField, srcPlayer):
     for kadeLine in context.kades[ArabolyRandom(limit=len(context.kades))]:
         output = ArabolyGenerals._push_output(channel, context, output, kadeLine.rstrip("\n"), outputLevel=ArabolyOutputLevel.LEVEL_GRAPHICS)
     srcPlayer = context.players["byName"][src]
     if not "hie" in srcPlayer:
         hieAmount = ArabolyRandom(limit=8000, min=200)
         output = ArabolyGenerals._push_output(channel, context, output, "Yay! Kade gives {src} {hieAmount}ug LSD!".format(**locals()), delay=1)
         output = ArabolyGenerals._push_output(channel, context, output, "Awfom! {src} is tripping balls!".format(**locals()), delay=1.5)
         output = ArabolyGenerals._push_output(channel, context, output, "{src} looks at the board!".format(**locals()), delay=2)
         srcPlayer["hie"] = True
         output = ArabolyGenerals._board(channel, context, output, src)
     elif "hie" in srcPlayer:
         output = ArabolyGenerals._push_output(channel, context, output, "Oh no! Kade takes away {src}'s LSD trip!".format(**locals()), delay=1)
         output = ArabolyGenerals._push_output(channel, context, output, "Oops! {src} is no longer hie!".format(**locals()), delay=1.5)
         del srcPlayer["hie"]
     return context, output, srcField, srcPlayer
Пример #6
0
 def _land_chance_redist(args, channel, context, output, randsFromArgs, src, srcPlayer):
     if not randsFromArgs:
         srcWealth = ArabolyRandom(limit=int(srcPlayer["wallet"] * 0.15), min=int(srcPlayer["wallet"] * 0.05))
         while True:
             targetPlayerNum = ArabolyRandom(limit=len(context.players["numMap"]))
             if  context.players["numMap"][targetPlayerNum] != None  \
             and targetPlayerNum != srcPlayer["num"]:
                 break
     else:
         srcWealth, targetPlayerNum = int(args[1]), int(args[2])
     if context.clientParams["recording"]:
         context.clientParams["recordingXxxLastArgs"] += [srcWealth, targetPlayerNum]
     targetPlayer = context.players["byName"][context.players["numMap"][targetPlayerNum]]
     srcPlayer["wallet"] -= srcWealth; targetPlayer["wallet"] += srcWealth;
     output = ArabolyGenerals._push_output(channel, context, output, "Oh my! Kade redistributes ${srcWealth} of {src}'s wealth to {targetPlayer[name]}!".format(**locals()), delay=3)
     return context, output, srcPlayer
Пример #7
0
 def _land_chance_bank(args, channel, context, output, randsFromArgs, src, srcPlayer):
     if not randsFromArgs:
         srcWealth = ArabolyRandom(limit=int(srcPlayer["wallet"] * 0.15), min=int(srcPlayer["wallet"] * 0.05))
     else:
         srcWealth = int(args[1])
     if context.clientParams["recording"]:
         context.clientParams["recordingXxxLastArgs"] += [srcWealth]
     srcPlayer["wallet"] -= srcWealth
     output = ArabolyGenerals._push_output(channel, context, output, "Oh no! Kade gives ${srcWealth} of {src}'s wealth to the bank!".format(**locals()), delay=3)
     return context, output, srcPlayer
Пример #8
0
 def _land_sectioned(channel, context, output, src, srcField, srcPlayer):
     for kadeLine in context.kades[ArabolyRandom(limit=len(context.kades))]:
         output = ArabolyGenerals._push_output(channel, context, output, kadeLine.rstrip("\n"), outputLevel=ArabolyOutputLevel.LEVEL_GRAPHICS)
     illnessPrefix = ["acute ", "latent ", "therapy-resistant ", "undifferentiated ", ""][ArabolyRandom(limit=5)]
     illnessTherapy = ["Antipsychotics Treatment", "Cat Room Therapy", "Electroconvulsive Therapy"][ArabolyRandom(limit=3)]
     illnessType = ["Bipolar", "Clinical Depression", "Lethally Severe Autism", "OCPD", "Schizophrenia"][ArabolyRandom(limit=5)]
     output = ArabolyGenerals._push_output(channel, context, output, "Dr Kade thinks!", delay=1)
     output = ArabolyGenerals._push_output(channel, context, output, "Dr Kade is thinking!", delay=2)
     output = ArabolyGenerals._push_output(channel, context, output, "Oh dear! Dr Kade diagnoses {src} with {illnessPrefix}{illnessType} and recommends immediate {illnessTherapy}!".format(**locals()), delay=3)
     output = ArabolyGenerals._push_output(channel, context, output, "Oh no! {src} is confined to the loony bin until having rolled doubles!".format(**locals()))
     srcPlayer["loonyBinTurns"] = 0
     return context, output, srcField, srcPlayer
Пример #9
0
 def _land_chance_swap(args, channel, context, output, randsFromArgs, src, srcPlayer):
     if not randsFromArgs:
         while True:
             targetPlayerNum = ArabolyRandom(limit=len(context.players["numMap"]))
             if  context.players["numMap"][targetPlayerNum] != None  \
             and targetPlayerNum != srcPlayer["num"]:
                 break
     else:
         targetPlayerNum = int(args[1])
     if context.clientParams["recording"]:
         context.clientParams["recordingXxxLastArgs"] += [targetPlayerNum]
     targetPlayer = context.players["byName"][context.players["numMap"][targetPlayerNum]]
     srcPlayer["field"], targetPlayer["field"] = targetPlayer["field"], srcPlayer["field"]
     output = ArabolyGenerals._push_output(channel, context, output, "Oops! Kade swaps {src} with {targetPlayer[name]}!".format(**locals()), delay=3)
     return context, output, srcPlayer
Пример #10
0
 def dispatchTimer(channel, context, nextExpire, output, subtype):
     if subtype == "attract":
         for attractLine in context.graphics["attract"][ArabolyRandom(
                 limit=len(context.graphics["attract"]))]:
             output = ArabolyGenerals._push_output(
                 channel,
                 context,
                 output,
                 attractLine.rstrip("\n"),
                 outputLevel=ArabolyOutputLevel.LEVEL_GRAPHICS)
         output += [{
             "eventType": "timer",
             "channel": channel,
             "expire": nextExpire,
             "nextExpire": nextExpire,
             "subtype": "attract"
         }]
     return channel, context, nextExpire, output, subtype
Пример #11
0
 def _land_chance_mortgage(args, channel, context, output, randsFromArgs, src, srcPlayer):
     if len(srcPlayer["properties"]):
         if not randsFromArgs:
             srcPropNum = ArabolyRandom(limit=len(srcPlayer["properties"]))
         else:
             srcPropNum = int(args[1])
         if context.clientParams["recording"]:
             context.clientParams["recordingXxxLastArgs"] += [srcPropNum]
         srcProp = context.board[srcPlayer["properties"][srcPropNum]]
         if srcProp["mortgaged"]:
             srcProp["mortgaged"] = False
             output = ArabolyGenerals._push_output(channel, context, output, "Yay! Kade accidentally lifts the mortgage on {src}'s {srcProp[title]}!".format(**locals()), delay=3)
         else:
             srcProp["mortgaged"] = True
             output = ArabolyGenerals._push_output(channel, context, output, "Oh dear! Kade accidentally mortgages {src}'s {srcProp[title]}!".format(**locals()), delay=3)
     else:
         output = ArabolyGenerals._push_output(channel, context, output, "Hm! Kade feels stupid!", delay=3)
     return context, output, srcPlayer
Пример #12
0
 def _prop_recv(channel, context, field, output, newOwner=None, price=None):
     for buyString in field["strings"][ArabolyStringType.DEVELOP][0]:
         rands = [ArabolyRandom(limit=150 - 5, min=5) for x in range(10)]
         output = ArabolyGenerals._push_output(
             channel, context, output,
             buyString.format(owner=newOwner,
                              prop=field["title"],
                              rands=rands))
     field["owner"] = newOwner
     context.players["byName"][newOwner]["properties"] += [field["field"]]
     context.players["byName"][newOwner]["wallet"] -= price
     if field["type"] == ArabolyGameField.PROPERTY:
         hasGroupFields = True
         for otherFieldNum in field["groupFields"]:
             otherField = context.board[otherFieldNum]
             if otherField["owner"] != newOwner:
                 hasGroupFields = False
                 break
         if hasGroupFields:
             for otherFieldNum in field["groupFields"]:
                 otherField = context.board[otherFieldNum]
                 otherField["ownerHasGroup"] = True
     return context, field, output
Пример #13
0
 def dispatch_develop(args, channel, context, output, src, status):
     if context.players["numMap"][context.players["curNum"]] != src  \
     or len(args) != 2                                               \
     or not args[0].isdigit() or not args[1].isdigit()               \
     or int(args[0]) >= len(context.board)                           \
     or int(args[1]) == 0 or int(args[1]) > 3:
         status = False
     else:
         fieldNum, newLevel = int(args[0]), int(args[1])
         field, srcPlayer = context.board[fieldNum], context.players[
             "byName"][src]
         if  field["type"] != ArabolyGameField.CHRONO                \
         and field["type"] != ArabolyGameField.PROPERTY              \
         and field["type"] != ArabolyGameField.UTILITY:
             status = False
         elif not ArabolyStringType.DEVELOP in field["strings"]:
             status = False
         else:
             if context.players["difficulty"] == "hard":
                 devCost = field["devCost"] * 2
             else:
                 devCost = field["devCost"]
         if devCost >= srcPlayer["wallet"]                           \
         or field["mortgaged"]                                       \
         or field["owner"] != src:
             status = False
         elif field["type"] == ArabolyGameField.CHRONO:
             if not (field["level"] == 0 and newLevel == 1):
                 status = False
             else:
                 field["level"] = newLevel
                 for developString in field["strings"][
                         ArabolyStringType.DEVELOP][newLevel]:
                     rands = [
                         ArabolyRandom(limit=150 - 5, min=5)
                         for x in range(10)
                     ]
                     output = ArabolyGenerals._push_output(
                         channel, context, output,
                         developString.format(owner=src,
                                              prop=field["title"],
                                              rands=rands))
                 srcPlayer["wallet"] -= devCost
         else:
             if  not field["ownerHasGroup"]                          \
             and context.players["difficulty"] != "hard":
                 status = False
             elif field["level"] == newLevel:
                 status = False
             else:
                 if context.players["difficulty"] != "hard":
                     for otherFieldNum in field["groupFields"]:
                         otherField = context.board[otherFieldNum]
                         if  otherField["level"] != newLevel         \
                         and otherField["level"] != (newLevel - 1):
                             status = False
                             break
                 if status:
                     field["level"] = newLevel
                     for developString in field["strings"][
                             ArabolyStringType.DEVELOP][newLevel]:
                         rands = [
                             ArabolyRandom(limit=150 - 5, min=5)
                             for x in range(10)
                         ]
                         output = ArabolyGenerals._push_output(
                             channel, context, output,
                             developString.format(owner=src,
                                                  prop=field["title"],
                                                  rands=rands))
                     srcPlayer["wallet"] -= devCost
     return args, channel, context, output, src, status
Пример #14
0
 def _land_chest(channel, context, output, src, srcField, srcPlayer):
     for kadeLine in context.kades[ArabolyRandom(limit=len(context.kades))]:
         output = ArabolyGenerals._push_output(channel, context, output, kadeLine.rstrip("\n"), outputLevel=ArabolyOutputLevel.LEVEL_GRAPHICS)
     return context, output, srcField, srcPlayer