From bd3a9866994e12c91e6f199f0b13509f7c29976a Mon Sep 17 00:00:00 2001 From: Brosef Date: Wed, 16 Jul 2025 12:08:22 +0100 Subject: [PATCH] Added expansion manager implementation --- game.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/game.py b/game.py index df7acd6..9e0b483 100644 --- a/game.py +++ b/game.py @@ -2,9 +2,16 @@ import logging import pygame import random import gameUtils +import NoPELib #Oh god here we go. I'm gonna screw up this entire thing +def transform(value, minA, maxA, minB, maxB): + """ + Translates `value` from `minA`-`maxA` to `minB`-`maxB`. + """ + return ((value - minA) / (maxA - minA)) * (maxB - minB) + minB + class Game(gameUtils.Game): def __init__(self, *args, **kwargs): """ @@ -18,8 +25,8 @@ class Game(gameUtils.Game): # Don't remove this. It does important things. :3 super().__init__(*args, **kwargs) + self.em = NoPELib.ExpansionsManager(self.pm, includeExpansions=['ShockColar1']) - # TODO: Utilise self.pm (the player manager) # TODO: Utilise the following new sounds: # gun-load: Should be played at the beginning of the game, # and should have an animation accompanying it. @@ -94,7 +101,13 @@ class Game(gameUtils.Game): if random.randint(1,6) == 6: self.playSound(self.gunShot) self.gun.playAnim('fire') - self.currentlyPlaying.punish(self.shockScale) + expansionIDs = self.em.lookupPlayer(self.currentlyPlaying.name) + shocker = self.em[expansionIDs[0]] + iMin, iMax = self.currentlyPlaying.expansions['ShockCollar1']['shcokRange'] + v = round(transform(self.shockScale, 0, 1, iMin, iMax)) + + print(f'Shocking {self.currentlyPlaying.name} with intensity {v}') + shocker.step((False, 0.5, v)) print(f'{self.currentlyPlaying.name} is fucking dead.') return 0.04 #remember to add shock