generated from acm-ndsu/byte_le_engine
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Events #36
Merged
Events #36
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
89d9ac0
Added RoadType and DisasterType to enums
qastanley cca3817
Added length modifier to road
qastanley 6ae24e2
Added road_type as parameter for road
qastanley 0517fa8
Merge remote-tracking branch 'origin/dev' into quinn
qastanley 89caf4d
Connect road types to event types
qastanley 95dd61c
EventHandler Logic
qastanley f76cde2
Merge remote-tracking branch 'origin/dev' into quinn
qastanley 8d10307
Moved event_handler
qastanley a831f7f
Changed possible event types from sets to lists (for weighting)
qastanley 509189a
Merge remote-tracking branch 'origin/dev' into quinn
qastanley d1bd0d3
Added missing name in get city by name
c769dec
Game successfully runs
60f93ae
Moved event weights to GameStats
qastanley 8191bb7
Truck upgrades now prevent certain events
qastanley 9e1b60d
Merge branch 'dev' into quinn
qastanley a67ea9f
event_chance method
qastanley 9b04b99
Moved adjusted event weights to event controller
qastanley 07e2e13
Added comments for event weights
qastanley f7c837d
Update master_controller.py
qastanley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from game.common.stats import GameStats | ||
from game.common.enums import EventType | ||
import random | ||
|
||
def trigger_event(road, player): | ||
qastanley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Picks random event type from those possible on given road | ||
possible_event_type_count = len(GameStats.possible_event_types[road.road_type]) | ||
chosen_event_type = EventType.none | ||
if possible_event_type_count == 4: | ||
chosen_event_type = random.choices(GameStats.possible_event_types[road.road_type], weights=[4,3,2,1], k=1) | ||
qastanley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if possible_event_type_count == 3: | ||
chosen_event_type = random.choices(GameStats.possible_event_types[road.road_type], weights=[3,2,1], k=1) | ||
if possible_event_type_count == 2: | ||
chosen_event_type = random.choices(GameStats.possible_event_types[road.road_type], weights=[2,1], k=1) | ||
# Deal damage based on event | ||
player.truck.health -= GameStats.event_type_damage[chosen_event_type] | ||
# Reduce remaining time based on event | ||
player.time -= GameStats.event_type_time[chosen_event_type] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event_controller needs a method that determines if an event happens.