Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Birchee/Brichard Organism and TurnStartEvent class #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, player1, player2):
self._actions_buffer = []
self._shuffle_water = False
self._start()
self.turn_start_events = []
self.turn_end_events = []

def draw(self):
Expand Down Expand Up @@ -153,6 +154,16 @@ def process_move(self, index, player_inputs):
# Shuffling water tiles at start of turn
if self._shuffle_water:
self._shuffle_water_tiles()

# Running turn start events
# Birchee's berries come on YOUR turn. Added check for player against game's curr_player
print(self.turn_start_events)
for event in self.turn_start_events:
if self.curr_player == event.curr_player:
event.act()

# Removing unsubscribed turn start events
self.turn_start_events = [event for event in self.turn_start_events if event.subscribed]
return 1

def _shuffle_water_tiles(self):
Expand Down
45 changes: 42 additions & 3 deletions Organism.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ def ability(self):
self.game.next_player.change_HP(-20)
self.game.grid.convert_tiles(self.mana_type_index, 2)

class TurnStartEvent(ABC):
def __init__(self, max_num_turns_active, game):
self.curr_num_turns_active = 0
self.max_num_turns_active = max_num_turns_active
self.game = game
# Caching the players, cause current and next player switch around
self.curr_player = self.game.curr_player
self.next_player = self.game.next_player
self.subscribed = True

def act(self):
# Unsubscribing the event
self.curr_num_turns_active += 1
if self.curr_num_turns_active == self.max_num_turns_active:
self.subscribed = False

class TurnEndEvent(ABC):
def __init__(self, max_num_turns_active, game):
Expand Down Expand Up @@ -229,7 +244,7 @@ def __init__(self):

def ability(self):
self.game.next_player.change_HP(-15)
self.game.turn_end_events.append(Starblitz(2, self.game))
self.game.turn_start_events.append(Starblitz(1, self.game))


class Winklit(Organism):
Expand All @@ -238,7 +253,7 @@ def __init__(self):

def ability(self):
self.game.next_player.change_HP(-10)
self.game.turn_end_events.append(Starblitz(2, self.game))
self.game.turn_start_events.append(Starblitz(1, self.game))


class Flambagant(Organism):
Expand Down Expand Up @@ -319,6 +334,30 @@ def __init__(self):
def ability(self):
self.game.next_player.change_HP(-35)
self.game.turn_end_events.append(Punish(2, self.game))

class Harvest(TurnStartEvent):
def __init__(self, max_num_turns_active, game, berries):
super().__init__(max_num_turns_active, game)
self.berries = berries

def act(self):
self.curr_player.change_num_berries(berries)
super().act()

class Birchard(Organism):
def __init__(self):
super().__init__("Birchard", 'Harvest+: Attacks for 15 HP & adds 2 berries at the start of your next turn.', 5, mana_indexes['grass'], None)

def ability(self):
self.game.next_player.change_HP(-15)
self.game.turn_start_events.append(Harvest(1, self.game, 2))

class Birchee(Organism):
def __init__(self):
super()__init__("Birchee", 'Harvest: Attacks for 10 HP & adds 1 berry on your next turn for 2 turns.', 6, mana_indexes['grass'], Birchard)

stage_1_organisms = [Bonzumi(), Pelijet(), Turtleisk(), Slickitty(), Barbenin(), Pyrokun(), Trashark(), Elfini(), Winklit(), Timingo(), Criminook(), Nerverack()]
def ability(self):
self.game.next_player.change_HP(-10)
self.game.turn_start_events.append(Harvest(2, self.game, 1))

stage_1_organisms = [Bonzumi(), Pelijet(), Turtleisk(), Slickitty(), Barbenin(), Pyrokun(), Trashark(), Elfini(), Winklit(), Timingo(), Criminook(), Nerverack(), Birchee()]