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

Dynamic Event Chance #52

Merged
merged 44 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
89d9ac0
Added RoadType and DisasterType to enums
qastanley Oct 17, 2020
cca3817
Added length modifier to road
qastanley Oct 17, 2020
6ae24e2
Added road_type as parameter for road
qastanley Oct 17, 2020
0517fa8
Merge remote-tracking branch 'origin/dev' into quinn
qastanley Oct 17, 2020
89caf4d
Connect road types to event types
qastanley Oct 21, 2020
95dd61c
EventHandler Logic
qastanley Oct 31, 2020
f76cde2
Merge remote-tracking branch 'origin/dev' into quinn
qastanley Oct 31, 2020
8d10307
Moved event_handler
qastanley Oct 31, 2020
a831f7f
Changed possible event types from sets to lists (for weighting)
qastanley Oct 31, 2020
509189a
Merge remote-tracking branch 'origin/dev' into quinn
qastanley Oct 31, 2020
d1bd0d3
Added missing name in get city by name
Nov 1, 2020
c769dec
Game successfully runs
Nov 1, 2020
60f93ae
Moved event weights to GameStats
qastanley Nov 7, 2020
8191bb7
Truck upgrades now prevent certain events
qastanley Nov 14, 2020
9e1b60d
Merge branch 'dev' into quinn
qastanley Nov 14, 2020
a67ea9f
event_chance method
qastanley Nov 14, 2020
9b04b99
Moved adjusted event weights to event controller
qastanley Nov 14, 2020
07e2e13
Added comments for event weights
qastanley Nov 14, 2020
f7c837d
Update master_controller.py
qastanley Nov 18, 2020
6c62c9e
Merge branch 'dev' into quinn
qastanley Dec 15, 2020
d2f865d
Updated move action for new map
qastanley Dec 15, 2020
1c98119
Event trigger added to movement
qastanley Dec 19, 2020
d9e60a7
Added gas usage to move
qastanley Jan 2, 2021
bad779a
Merge branch 'quinn' of https://github.com/PixPanz/byte_le_royale_202…
qastanley Jan 2, 2021
18fe8e5
Merge branch 'dev' into quinn
qastanley Jan 6, 2021
bf818b7
Merge branch 'dev' into quinn
qastanley Jan 9, 2021
6297200
Merge branch 'dev' into quinn
qastanley Jan 9, 2021
b77cf87
Merge branch 'dev' into quinn
qastanley Jan 16, 2021
bfed8c9
Changed damage and time values to be based on how often events happen
qastanley Jan 20, 2021
457e2b9
Removed unnecessary event type bonuses
qastanley Jan 23, 2021
05abefb
Merge remote-tracking branch 'origin/dev' into quinn
qastanley Jan 23, 2021
01092c0
Merge branch 'dev' into quinn
qastanley Jan 27, 2021
4e6241b
Merge branch 'quinn' of https://github.com/PixPanz/byte_le_royale_202…
qastanley Jan 27, 2021
e959aba
Added base for high speed-risk
qastanley Jan 30, 2021
c124d95
Balance pass on upgrades
qastanley Jan 30, 2021
165dffe
added monster truck to enums
qastanley Jan 30, 2021
624e7d1
Merge branch 'dev' into quinn
qastanley Jan 30, 2021
0a75a2a
Merge branch 'dev' into quinn
qastanley Jan 30, 2021
3265165
Fixed issues with last PR
qastanley Jan 30, 2021
c04a5bd
Refactored event controller
qastanley Jan 30, 2021
cb87dfe
Event chance now scales with truck speed
qastanley Feb 4, 2021
17bf617
Merge branch 'dev' into quinn
qastanley Feb 4, 2021
6983bb8
added set_speed action
qastanley Feb 4, 2021
ac0bb5d
Bug fixes
qastanley Feb 5, 2021
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
1 change: 1 addition & 0 deletions game/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ActionType:
select_contract = 4
choose_speed = 5
heal = 6
set_speed = 7

class Region:
none = 0
Expand Down
2 changes: 1 addition & 1 deletion game/common/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class GameStats:

maximum_gas_price = 5

truck_maximum_speed = 80
truck_maximum_speed = 100

contract_node_count = {
'short': 8,
Expand Down
9 changes: 4 additions & 5 deletions game/controllers/action_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ def handle_actions(self, player):
self.heal(player)
elif(player_action == ActionType.upgrade):
self.upgrade_level(player, player.action.action_parameter)

elif(player_action == ActionType.choose_speed):
elif(player_action == ActionType.set_speed):
#This is an ActionType because the user client cannot directly influence truck values.
player.truck.set_current_speed(player.action_parameter)
player.truck.set_current_speed(player.action.action_parameter)

else:
self.print("Action aborted: no active contract!")

# Action Methods ---------------------------------------------------------
# Action Methods ---------------------------------------------------------
def move(self, player):
road = player.action.action_parameter

Expand All @@ -68,7 +67,7 @@ def move(self, player):
for route in self.current_location.roads:
if route == road: #May need to be redone
player.truck.current_node = self.current_location.next_node
self.event_controller.trigger_event(road, player, player.truck)
self.event_controller.event_chance(road, player, player.truck)
time_taken = (road.length / player.truck.get_current_speed()) * luck
gas_used = (road.length/(GameStats.truck_starting_mpg * fuel_efficiency))/(GameStats.truck_starting_max_gas*100)
player.truck.body.current_gas -= gas_used
Expand Down
12 changes: 6 additions & 6 deletions game/controllers/event_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from game.controllers.controller import Controller
import random
from game.controllers.controller import Controller
import math


class EventController(Controller):
Expand All @@ -21,12 +22,11 @@ def trigger_event(self, road, player, truck):
player.time -= GameStats.event_type_time[chosen_event_type] * (1 - mods['DamageMod'])

def event_chance(self, road, player, truck):
#evaluate 25% chance
happens = random.choices(
[True, False], weights=GameStats.base_event_probability, k=1)[0]
#event chance 25% -> 40% if truck going really fast
if (truck.get_current_speed > 70):
happens = random.choices([True, False], weights=[40,60], k=1)[0]
if (truck.get_current_speed() > 50):
chance = .0295*((truck.get_current_speed() - 50)**2) + 25.612
else:
chance = 15*(math.log10(truck.get_current_speed()+1))
happens = random.choices([True, False], weights=[chance, 100-chance],k=1)[0]
if happens:
self.trigger_event(road, player, truck)

Expand Down