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

Create-upgrade-object #50

Merged
merged 16 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from 12 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
30 changes: 30 additions & 0 deletions game/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,33 @@ class ObjectType:
action = 1
player = 2
game_board = 3

class Upgrades:
none = 0
gun_upgrades = 1
movement_upgrades = 2
sight_upgrades = 3
handgun = 1
assault_rifle = 2
shotgun = 3
sniper = 4


class GunLevel:
level_zero = 0
level_one = 1
level_two = 2
level_three = 3


class ShotPattern:
HagenSR marked this conversation as resolved.
Show resolved Hide resolved
none = 0
single = 1
multi = 2
spread = 3

class Upgrades:
none = 0
gun_upgrades = 1
movement_upgrades = 2
sight_upgrades = 3
27 changes: 27 additions & 0 deletions game/common/items/upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from game.common.enums import Upgrades
from game.common.map_object import MapObject
from game.common.items import Item


class Upgrade(Item):

def __init__ (self, coordinates, hitbox, health, count, upgrade_enum = None, movement_enum = None, sight_enum = None ):
super().__init__(coordinates, hitbox, health, count)
self.upgrade_enum = upgrade_enum
self.movement_enum = movement_enum
self.sight_enum = sight_enum

def to_json(self):
data = super().to_json()
data[upgrade_enum] = self.upgrade_enum
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keys in a dictionary should be strings. You can use a variable but I don't think this is will result in the desired output you want

data[movement_enum] = self.movement_enum
data[sight_enum] = self.sight_enum
return data

def from_json(self, data):
super.from_json(data)
self.upgrade_enum = data[upgrade_enum]
self.movement_enum = data[movement_enum]
self.sight_enum = data[sight_enum]


1 change: 1 addition & 0 deletions game/common/map_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from game.common.game_object import GameObject
from game.common.enums import *


class MapObject(GameObject):
def __init__(self, health=None, coordinates=None, hitbox=None, collidable=None):
super().__init__()
Expand Down
47 changes: 45 additions & 2 deletions game/common/stats.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@

from game.common.enums import *

class GameStats:
game_board_width = 500
game_board_height = 500

default_wall_health = 50

player_stats = {
'starting_health': 10,
'starting_money': 10,
'starting_coordinates': [{'x': 450, 'y': 450}, {'x': 50, 'y': 50}],
'hitbox': {'width': 10, 'height': 10}
'hitbox': {'width': 10, 'height': 10},
'view_radius': 10,
'move_speed': 10,
}

moving_object_stats = {
# max speed value is arbitrary at this time and will most likely be changed
'max_speed': 500
}

damaging_object_stats = {
# This is assuming the player is at the very edge of board and the object
# only stops once it hits an object.
'max_range': 500,

# This determines the max damage an object instance to do, value
# is arbitrary for now and will be changed when necessary
'max_damage': 100
}

# Placeholder stats, stats may be created for all gun levels
gun_stats = {
GunType.none: {'pattern': ShotPattern.none, 'damage': 0,
'fire_rate': 0, 'range': 0, 'mag_size': 0, 'reload_speed': 0,
'cooldown': {'max': 0, 'rate': 0}, 'level_mod': 1},
GunType.handgun: {'pattern': ShotPattern.single, 'damage': 1,
'fire_rate': 2, 'range': 30, 'mag_size': 13, 'reload_speed': 3,
'cooldown': {'max': 8, 'rate': 2}, 'level_mod': 1.25},
GunType.assault_rifle: {'pattern': ShotPattern.multi, 'damage': 1,
'fire_rate': 5, 'range': 50, 'mag_size': 30, 'reload_speed': 6,
'cooldown': {'max': 15, 'rate': 5}, 'level_mod': 1.25},
GunType.shotgun: {'pattern': ShotPattern.spread, 'damage': 8,
'fire_rate': 1, 'range': 10, 'mag_size': 2, 'reload_speed': 8,
'cooldown': {'max': 1, 'rate': 1}, 'level_mod': 1.25},
GunType.sniper: {'pattern': ShotPattern.single, 'damage': 9,
'fire_rate': 1, 'range': 100, 'mag_size': 1, 'reload_speed': 8,
'cooldown': {'max': 1, 'rate': 1}, 'level_mod': 1.25}
}

Upgrades.gun_upgrades = 20 #Could potentially incease bullet speed?
Upgrades.movement_upgrades = 20 #May be used to make the player go faster?
Upgrades.sight_upgrades = 20 #Increase how far player can see?
13 changes: 13 additions & 0 deletions game/common/upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from game.common.enums import Upgrades


class Upgrade:
Mitchell-Borders marked this conversation as resolved.
Show resolved Hide resolved
bullet_speed_increase = {
Upgrades.gun_upgrades: 20,
Mitchell-Borders marked this conversation as resolved.
Show resolved Hide resolved
}
player_speed_increase = {
Upgrades.movement_upgrades: 20,
}
player_sight_increase = {
Upgrades.sight_upgrades: 20,
}
Mitchell-Borders marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions game/common/walls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from game.common.map_object import MapObject
from game.common.stats import GameStats


class Wall(MapObject):
def __init__(self, coordinates, hitbox, health = GameStats.default_wall_health, destructible = False, collidable = True):
super().__init__(health, coordinates, hitbox, collidable )
self.destructible = destructible

def to_json(self):
data = super().to_json()
data['destructible'] = self.destructible
return data

def from_json(self, data):
super().from_json(data)
self.destructible = data['destructible']