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

add experience system #2

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion characters/player/death_environment.tres
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[resource]
background_mode = 1
background_sky = SubResource( 1 )
background_sky_orientation = Basis( -1, -1.50996e-07, 0, 1.50996e-07, -1, 0, 0, 0, 1 )
background_sky_orientation = Basis( -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0, 0, 1 )
background_sky_rotation = Vector3( 0, 0, 3.14159 )
background_sky_rotation_degrees = Vector3( 0, 0, 180 )
background_color = Color( 0.835294, 0.835294, 0.835294, 1 )
Expand Down
21 changes: 20 additions & 1 deletion characters/state/experience_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,38 @@ var sturdiness: float
var concentration: float
var endurance: float

enum level {
novice,
apprentice,
master,
grandmaster,
god
}

var masteries: Dictionary = {}

# TODO: xp system
func experience_progress() -> float:
return util.max(util.fract(sturdiness), util.fract(concentration), util.fract(endurance))
return (sturdiness + concentration + endurance) / 8000.0 # return character "value"

func increase_mastery(element: int) -> int:
if(masteries.has(element)):
masteries[element] += 1
else:
masteries[element] = level.novice
return masteries[element]

func save(state_dict: Dictionary):
var _experience_state = state_dict.get("experience", {})
_experience_state["sturdiness"] = sturdiness
_experience_state["concentration"] = concentration
_experience_state["endurance"] = endurance
_experience_state["masteries"] = masteries
state_dict["experience"] = _experience_state

func init(state_dict: Dictionary):
var _experience_state = state_dict.get("experience", {})
sturdiness = _experience_state.get("sturdiness", 1.0)
concentration = _experience_state.get("concentration", 1.0)
endurance = _experience_state.get("endurance", 1.0)
masteries = _experience_state.get("masteries", {})