def __init__(self): Game = self pygame.init() self.__previousState = GameState() Config.Init() Display.Init() self.__screen = Display.GetDisplay() Display.SetCaption(Config.Get("GameSettings")["Caption"]) self.Clock = Clock().SetTick(int(Config.Get("GameSettings")["Fps"])) self.__gameObjects = []
def runTest(self): c = Config() c.Set("RaNDom", "trollol") self.assertEqual(c.Get("RANDOM"), "trollol")
def runTest(self): c = Config() self.assertEqual(c.Get("NotExistsss"), None)
def runTest(self): c = Config() c.Set("Value", "roflcopter") self.assertEqual(c.Get("Value"), "roflcopter")
def runTest(self): c = Config() c.Set("Nil", None) self.assertEqual(c.Get("Nil"), '')
class PlayerS(Player): Config.Init() SPRITE_WIDTH = 16 SPRITE_HEIGHT = 16 SPRITE_SHEET_PATH = Config.Get("ResourcePath") SPRITE_SHEET = pygame.image.load(SPRITE_SHEET_PATH) SPRITE_SHEET.set_clip(pygame.Rect(0, 0, SPRITE_WIDTH, SPRITE_HEIGHT)) MAX_VELOCITY_WALKING = 20 MAX_VELOCITY_RUNNING = 30 RIGHT = 0 LEFT = 1 def __init__(self, pos, vel, size, stats, multiplier=1, facing=RIGHT): super().__init__(pos[0], pos[1], size[0], size[1], stats) Display.Init() self.pos = pos self.vel = vel self.size = size self.facing = facing self.maxVel = PlayerS.MAX_VELOCITY_WALKING self.multiplier = multiplier self.landed = True def Update(self): keys = pygame.key.get_pressed() for key in keys: if (key == pygame.key.K_SPACE): if (self.landed): self.vel[1] += 20 * self.multiplier if (key == pygame.key.K_a): self.vel[0] -= 5 * self.multiplier if (key == pygame.key.K_d): self.vel[0] += 5 * self.multiplier if (key == pygame.key.K_LSHIFT): self.maxVel = MAX_VELOCITY_RUNNING if (self.vel[0] < 0): self.facing = LEFT if (self.vel[0] > 0): self.facing = RIGHT def Draw(self): display = Display.GetDisplay() player = PlayerS.SPRITE_SHEET.subsurface( PlayerS.SPRITE_SHEET.get_clip()) display.blit(player, (50, 50)) def Collides(self, collideObj, collisionState): if (instanceof(collideObj, WorldObject)): self.grounded = true if (instanceof(collideObj, Projectile)): self.health -= collideObj.Damage if (instanceof(collideObj, MeleeWeapon)): self.health -= collideObj.Damage
from slackclient import SlackClient from Config import Config import threading config = Config() channel = config.Get("slack_channel") token = config.Get("slack_api_key") sc = SlackClient(token) class Bot: def Post(self, message, icon): return sc.api_call("chat.postMessage", channel=config.Get("slack_channel"), text=message, username="******", icon_emoji=icon) def SingleReport(self, name, hostname, status): if config.Get("enable_slackbot"): message = "%s (%s) has just gone %s!", (name, hostname, status) self.Post(message, ":exclamation:") else: return 0