Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/dev' into quinn"
Browse files Browse the repository at this point in the history
This reverts commit 97aae8d, reversing
changes made to b8034a6.
  • Loading branch information
qastanley committed Aug 29, 2020
1 parent 97aae8d commit 5e4075f
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 219 deletions.
48 changes: 0 additions & 48 deletions game/common/contract.py

This file was deleted.

6 changes: 2 additions & 4 deletions game/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ class ObjectType:
player = 2
node = 3
truck = 4
contract = 5

class ActionType:
none = 0
select_route = 1
choose_speed = 2
buy_gas = 3
upgrade = 4
select_contract = 5

class Region:
class LocationType:
none = 0
grass_lands = 1
mount_vroom = 2
Expand All @@ -33,4 +31,4 @@ class RoadType:
none = 0
rural = 1
street = 2
highway = 3
highway = 3
51 changes: 51 additions & 0 deletions game/common/location_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from game.common.node import Node
from game.common.enums import LocationType
from game.common.stats import GameStats


class Grass_Lands(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.grass_lands
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.node_difficulty_modifier[self.location_type]


class Nord_Dakotia(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.nord_dakotia
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.location_difficulty_modifier[self.location_type]


class Mobave_Desert(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.mobave_desert
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.location_difficulty_modifier[self.location_type]


class Mount_Vroom(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.mount_vroom
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.location_difficulty_modifier[self.location_type]


class Loblantis(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.loblantis
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.location_difficulty_modifier[self.location_type]


class Tropical_Cop_Land(Node):
def __init__(self):
super().__init__()
self.location_type = LocationType.tropical_cop_land
self.reward_modifier = GameStats.location_reward_modifier[self.location_type]
self.difficulty_modifier = GameStats.location_difficulty_modifier[self.location_type]
5 changes: 1 addition & 4 deletions game/common/map.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#This needs to be a game object desperately
# STATIC METHODS BAAAAAAAAAAADDDDDDDDDDD
class Map():
#This needs work but oh well
cities = dict()
roads = dict()

# This part is probs obsolete
@staticmethod
def getRoadByName(name):
return roads[name]

# This part is probs obsolete
@staticmethod
def getCityByName(name):
return cities[name]
Expand Down
19 changes: 11 additions & 8 deletions game/common/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,36 @@
from game.common.map import Map

class Node(GameObject):

#Name is the key for this node in the graph it must be unique

def __init__(self, name):
super().__init__()
self.object_type = ObjectType.node
self.city_name = name
self.region = Region.none
self.location_type = LocationType.none
self.connections = list()
# registers this object to the graph with city_name as the key
Map.cities[self.city_name] = self

def to_json(self):
data = super().to_json()
data['region'] = self.region
data['location_type'] = self.location_type
data['city_name'] = self.city_name
data['connections'] = self.connections
return data

def from_json(self, data):
super().from_json(data)
self.region = data['region']
self.location_type = data['location_type']
self.city_name = data['city_name']
self.connections = data['connections']
Map.cities[self.city_name] = self

# this method connects two cities together and generates a road object
def Connect(self, cityToConnect, roadName):
def Connect(self,cityToConnect, roadName):
road = Road(roadName,self.city_name,cityToConnect.city_name)
self.connections.append(road.road_name)
return road






18 changes: 3 additions & 15 deletions game/common/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
from game.common.action import Action
from game.common.game_object import GameObject
from game.common.enums import *
from game.common.contract import Contract
from game.common.truck import Truck


class Player(GameObject):
# truck initialized with placeholder
def __init__(self, code=None, team_name=None, action=None, contract=None, truck=Truck("HUB"):
def __init__(self, code=None, team_name=None, action=None):
super().__init__()
self.object_type = ObjectType.player

Expand All @@ -18,8 +15,6 @@ def __init__(self, code=None, team_name=None, action=None, contract=None, truck=
self.team_name = team_name
self.code = code
self.action = action
self.truck = truck
self.active_contract = contract

def to_json(self):
data = super().to_json()
Expand All @@ -28,8 +23,6 @@ def to_json(self):
data['error'] = self.error
data['team_name'] = self.team_name
data['action'] = self.action.to_json() if self.action is not None else None
data['truck'] = self.truck.to_json()
data['active_contract'] = self.active_contract.to_json()

return data

Expand All @@ -41,15 +34,10 @@ def from_json(self, data):
self.team_name = data['team_name']
act = Action()
self.action = act.from_json(data['action']) if data['action'] is not None else None
truck = Truck()
self.truck = truck.from_json(data['truck'])
contract = Contract()
self.active_contract = contract.from_json(data['active_contract'])


def __str__(self):
p = f"""ID: {self.id}
Team name: {self.team_name}
Action: {self.action}
Contracts: {self.active_contract}
"""
return p
return p
51 changes: 0 additions & 51 deletions game/common/region.py

This file was deleted.

3 changes: 0 additions & 3 deletions game/common/road.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
import json

class Road(GameObject):
# name is the key for this edge, it must always be unique
# city1 and city2 are strings representing the keys of the connected cities
def __init__(self, name ,city1=None, city2=None):
super().__init__()
self.object_type = ObjectType.node
self.road_name = name
self.road_type = RoadType.none
self.city_1 = city1
self.city_2 = city2
# upon finishing up it adds itself to the graph. could add some errors if the key isn't unique
Map.roads[self.road_name] = self

def to_json(self):
Expand Down
30 changes: 15 additions & 15 deletions game/common/stats.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from game.common.enums import Region
from game.common.enums import LocationType


class GameStats:
region_reward_modifier = {
Region.grass_lands: .5,
Region.nord_dakotia: .6,
Region.mobave_desert: .7,
Region.mount_vroom: .8,
Region.loblantis: .8,
Region.tropical_cop_land: .9,
location_reward_modifier = {
LocationType.grass_lands: .5,
LocationType.nord_dakotia: .6,
LocationType.mobave_desert: .7,
LocationType.mount_vroom: .8,
LocationType.loblantis: .8,
LocationType.tropical_cop_land: .9,
}

region_difficulty_modifier = {
Region.grass_lands: .5,
Region.nord_dakotia: .6,
Region.mobave_desert: .7,
Region.mount_vroom: .8,
Region.loblantis: .8,
Region.tropical_cop_land: .9,
location_difficulty_modifier = {
LocationType.grass_lands: .5,
LocationType.nord_dakotia: .6,
LocationType.mobave_desert: .7,
LocationType.mount_vroom: .8,
LocationType.loblantis: .8,
LocationType.tropical_cop_land: .9,
}
19 changes: 8 additions & 11 deletions game/common/truck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@
from game.common.enums import *
from game.common.road import *
from game.common.map import Map
from game.common.node import Node

# Probably need to add some extra stuff
class Truck(GameObject):

def __init__(self, node = None):
super().__init__()
self.object_type = ObjectType.truck
self.current_node = node
self.contract_list = []
self.active_contract = None

def get_city_contracts(self):
return self.contract_list

def get_active_contract(self):
return self.active_contract

def to_json(self):
data = super().to_json()
Expand All @@ -28,5 +19,11 @@ def to_json(self):

def from_json(self, data):
super().from_json(data)
node = Node()
self.current_node = node.from_json(data['current_node'])
self.current_node = data['current_node']







Loading

0 comments on commit 5e4075f

Please sign in to comment.