Skip to content

Commit

Permalink
Merge branch 'master' into base-bot
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanAEckelberg committed Jan 3, 2024
2 parents 44e6aa5 + 9b02cea commit 4401318
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions game/common/avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def to_json(self) -> dict:
data['dynamite_active_ability'] = self.dynamite_active_ability.to_json()
data['landmine_active_ability'] = self.landmine_active_ability.to_json()
data['emp_active_ability'] = self.emp_active_ability.to_json()
data['defusal_active_ability'] = self.trap_defusal_active_ability.to_json()
# data['tech_tree'] = self.__tech_tree.to_json()
return data

Expand All @@ -403,4 +404,5 @@ def from_json(self, data: dict) -> Self:
self.dynamite_active_ability = DynamiteActiveAbility().from_json(data['dynamite_active_ability'])
self.landmine_active_ability = LandmineActiveAbility().from_json(data['landmine_active_ability'])
self.emp_active_ability = EMPActiveAbility().from_json(data['emp_active_ability'])
self.trap_defusal_active_ability = TrapDefusalActiveAbility().from_json(data['defusal_active_ability'])
return self
26 changes: 26 additions & 0 deletions visualizer/sprites/inventory/defusal_ability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pygame
import os

from game.utils.vector import Vector


class DefusalAbility(pygame.sprite.Sprite):
def __init__(self, top_left: Vector):
super().__init__()
self.images: list[pygame.Surface] = [
pygame.image.load(os.path.join(os.getcwd(), 'visualizer/spritesheets/inventory/defusal-deactivated-inventory.png')),
pygame.image.load(os.path.join(os.getcwd(), 'visualizer/spritesheets/inventory/defusal-activated-inventory.png'))
]
self.image: pygame.Surface = self.images[0]
self.activated: bool = False
self.rect = self.image.get_rect()
self.rect.topleft = top_left.as_tuple()

@property
def activated(self) -> bool:
return self.__activated

@activated.setter
def activated(self, activated) -> None:
self.__activated = activated
self.image = self.images[1 if self.__activated else 0]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions visualizer/templates/inventory_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from game.utils.vector import Vector
from visualizer.sprites.inventory.ancient_tech_inventory import AncientTechInventory
from visualizer.sprites.inventory.copium_inventory import CopiumInventory
from visualizer.sprites.inventory.defusal_ability import DefusalAbility
from visualizer.sprites.inventory.dynamite_ability import DynamiteAbility
from visualizer.sprites.inventory.emp_ability import EmpAbility
from visualizer.sprites.inventory.inventory_backdrop import InventoryBackdrop
Expand Down Expand Up @@ -60,6 +61,9 @@ def __init__(self, screen: pygame.Surface, topleft: Vector, size: Vector, font:
self.landmine_ability = LandmineAbility(top_left=Vector.add_vectors(topleft, Vector(y=200, x=225)))
self.landmine_ability.add(self.render_list)

self.defusal_ability = DefusalAbility(top_left=Vector.add_vectors(topleft, Vector(y=250, x=225)))
self.defusal_ability.add(self.render_list)

self.science: Science = Science(top_left=Vector.add_vectors(topleft, Vector(y=400, x=50)))

self.science.add(self.render_list)
Expand Down Expand Up @@ -100,6 +104,9 @@ def recalc_animation(self, turn_log: dict) -> None:
self.emp_ability.activated = (avatar['emp_active_ability']['is_usable']
and avatar['tech_tree']['EMPs'])

self.defusal_ability.activated = (avatar['defusal_active_ability']['is_usable']
and avatar['tech_tree']['Trap Defusal'])

def render(self) -> None:
super().render()
self.company_text.render()
Expand Down

0 comments on commit 4401318

Please sign in to comment.