コード例 #1
0
 def check(self, char: Character, state: State):
     target = state.getChar(self.targetShort)
     
     if self.relationship == RelationCheck.ALLY and char.isAllyOf(target):
         return True
     if self.relationship == RelationCheck.ENEMY and not char.isAllyOf(target):
         return True
     return False
コード例 #2
0
ファイル: MainCog.py プロジェクト: lapraas/hungergames-bot
 def getCharEmbed(char: Character, title="", description="", color=MISCORANGE) -> Embed:
     """ Initializes an Embed based on the given Character.
         Defaults to making the title the .string() of the Character,
         making the description empty,
         and making the color orange. """
     
     embed = Embed(title=char.string() if not title else title, description=description, color=color)
     url = char.getPicture()
     if url:
         embed.set_thumbnail(url=url)
     return embed
コード例 #3
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     toAlly = state.getChar(self.charShort)
     if char.isAlone() and toAlly.isAlone():
         alliance = []
         char.joinAlliance(alliance)
         toAlly.joinAlliance(alliance)
         return f"allied with: {toAlly}"
     elif not char.isAlone():
         alliance = char.getAlliance()
         toAlly.leaveAlliance()
         toAlly.joinAlliance(alliance)
         return f"alliance joined by: {toAlly}"
     elif not toAlly.isAlone():
         alliance = toAlly.getAlliance()
         char.leaveAlliance()
         char.joinAlliance(alliance)
         return f"joined alliance of: {toAlly}"
コード例 #4
0
    def chooseFromEvents(self,
                         char: Character,
                         events: list[Event] = None,
                         state: State = None) -> Optional[Event]:
        if not events:
            events = self.events.values()

        possibleEvents: list[Event] = []
        totalChance = 0
        defaultEvent: Optional[Event] = None

        for event in events:
            if event.prepare(char, self.tributes, state):
                if event.getChance() == 0:
                    defaultEvent = event
                    continue
                totalChance += event.getChance()
                possibleEvents.append(event)

        print(f"Character: {char}")
        print(f"  alive:\t{char.alive}")
        print(f"  age:\t{char.age}")
        print(f"  location:\t{char.location}")
        print(f"  status:\t{char.status}")
        print(f"  tags:")
        [print(f"    {tag}") for tag in char.tags]
        print(f"  inventory:\t{char.items}")
        print(f"  alliance:\t{char.alliance}")
        print(f"Possible events: {possibleEvents}")
        print(f"Default event: {defaultEvent}\n")

        if not possibleEvents:
            if defaultEvent:
                return defaultEvent
            else:
                raise Exception("No events matched when choosing from events")

        choice = randint(0, totalChance - 1)

        count = 0
        for event in possibleEvents:
            if choice >= count and choice < (count + event.getChance()):
                return event
            count = count + event.getChance()
        if not char.isAlive():
            return None
        raise Exception(
            f"Invalid choice when choosing from events ({choice} out of {totalChance})"
        )
コード例 #5
0
ファイル: All.py プロジェクト: lapraas/hungergames-bot
    def characterFromYaml(name: str, data: tuple[str, str]) -> Character:
        if not len(data) >= 2:
            raise LoadException(
                f"Couldn't load character {name}, too few elements in list ({data})"
            )

        gender = data[0]
        if gender == "male":
            pronouns = ["he", "him", "his", "his", "himself"]
        elif gender == "female":
            pronouns = ["she", "her", "her", "hers", "herself"]
        elif gender == "nonbinary":
            pronouns = ["they", "them", "their", "theirs", "themself"]
        else:
            pronouns = data[0].split(" ")
            if len(pronouns) != 5:
                raise LoadException(
                    f"Couldn't load Character {name}, there were not 5 values for the Character's pronouns ({pronouns})"
                )

        imgSrc = data[1]
        return Character(name, imgSrc, pronouns)
コード例 #6
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     char.addTag(self.tag, self.tagAge)
     return f"added tag: {self.tag}"
コード例 #7
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     char.kill()
     return f"killed: {char.string()}"
コード例 #8
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     char.revive()
     return f"revived: {char.string()}"
コード例 #9
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     item = state.getItem(self.itemShort)
     char.takeItem(item)
     return f"consumed item: {item}"
コード例 #10
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     if self.zone:
         char.move(self.zone)
     else:
         char.moveRandom()
     return f"moved to zone: {char.getLocation().name}"
コード例 #11
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State) -> str:
     char.clearStatus()
     return "cleared status"
コード例 #12
0
 def get(self, char: Character):
     return char.getItemByTags(self.itemTags)
コード例 #13
0
 def check(self, char: Character, state: State) -> bool:
     if self.state == AloneCheck.ALONE and char.isAlone():
         return True
     if self.state == AloneCheck.ALLIED and not char.isAlone():
         return True
     return False
コード例 #14
0
 def getVal(self, char: Character) -> int:
     return char.getTagAge(self.tag)
コード例 #15
0
 def check(self, char: Character, state: State) -> bool:
     if self.state == DistanceCheck.NEARBY:
         target = state.getChar(self.targetShort)
         return char.isNearby(target)
     else:
         return True
コード例 #16
0
 def check(self, char: Character, state: State) -> bool:
     if self.aState == AliveCheck.ALIVE:
         return char.isAlive()
     else:
         return not char.isAlive()
コード例 #17
0
 def check(self, char: Character, state: State) -> bool:
     return char.isIn(self.locName)
コード例 #18
0
 def check(self, char: Character, state: State) -> bool:
     return char.getItemByTags(self.itemTags) == False
コード例 #19
0
 def get(self, char: Character):
     return char.getItemByName(self.itemName)
コード例 #20
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     char.removeTag(self.tag)
     return f"removed tag: {self.tag}"
コード例 #21
0
 def check(self, char: Character, state: State) -> bool:
     if not char.hasStatus(self.status): return False
     super().check(char, state)
コード例 #22
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State) -> str:
     char.makeStatus(self.status)
     return f"set status: {self.status}"
コード例 #23
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     char.leaveAlliance()
     return "left alliance"
コード例 #24
0
ファイル: Effect.py プロジェクト: lapraas/hungergames-bot
 def perform(self, char: Character, state: State):
     item = state.getItem(self.itemShort)
     char.copyAndGiveItem(item)
     return f"gave item: {item}"
コード例 #25
0
 def check(self, char: Character, state: State) -> bool:
     if not char.hasTag(self.tag): return True if self.flip else False
     res = super().check(char, state)
     return (not res) if self.flip else res
コード例 #26
0
ファイル: main.py プロジェクト: licod3r/pykicker2
from game.Character import Character

print("Mr Blin is an idiot!")

lion = Character("Lion")
print("Here is %s" % lion.name)
コード例 #27
0
 def getVal(self, char: Character) -> int:
     return char.getStatusAge()