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

Adding team support in battles #51

Merged
merged 6 commits into from
May 17, 2022
Merged
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: 2 additions & 0 deletions Data/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GAMEMENU_ID,ID Card,Dresseur
GAMEMENU_SAVE,Save,Sauvegarde
GAMEMENU_SETTINGS,Settings,Paramètres
TEAMMANAGER_ORDER,Order,Ordre
TEAMMANAGER_SELECT,Select,Sélectionner
STAT_CHANGE_ATK,attack,L'attaque
STAT_CHANGE_DEF,defense,La défense
STAT_CHANGE_ATKSPE,special attack,L'attaque spéciale
Expand All @@ -30,6 +31,7 @@ BATTLE_BASEDIALOG_OPMON,OpMon,OpMon
BATTLE_BASEDIALOG_ITEMS,Items,Sac
BATTLE_BASEDIALOG_RUN,Run,Fuite
BATTLE_KO,{opmon} is KO!,{opmon} est KO !
BATTLE_OPMON_CHANGE,"Come back, {opmon1}! {opmon2}, go!","Reviens, {opmon1} ! {opmon2}, vas-y !"
MOVE_EFFECTIVENESS_NONE,But it's ineffective...,Mais c'est inefficace...
MOVE_EFFECTIVENESS_VERYLOW,It's barely effective...,C'est à peine efficace...
MOVE_EFFECTIVENESS_LOW,It's not very effective...,Ce n'est pas trés efficace...
Expand Down
14 changes: 8 additions & 6 deletions Objects/OpMon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func _init(p_nickname: String, p_species: Species, p_level: int, p_moves: Array,

# Returns the final statistics of the OpMon, with the in-battle modifications
func get_effective_stats() -> Array:
var effective_stats = stats
var effective_stats = stats.duplicate(true)
# Accuracy and evasion
effective_stats.append(100)
effective_stats.append(100)
Expand Down Expand Up @@ -79,10 +79,12 @@ func get_effective_name() -> String:
return tr(species.name)
else:
return nickname

func get_hp_string() -> String:

# Parameter: allows to get a hp string for a different hp
func get_hp_string(hp_p := -1) -> String:
var hp = self.hp if hp_p < 0 else hp_p
return String(hp) + " / " + String(stats[Stats.HP])


# In-battle modification of statistics, capped at ±6
# Returns the actual modification
Expand Down Expand Up @@ -126,7 +128,7 @@ class OpMove:
battle_scene.animate_move(MOVE_ANIMATIONS[data.move_animation])

# Checks if the move fails
if (100*randf()) > (data.accuracy * (user.stats[Stats.ACC] / opponent.stats[Stats.EVA])) and not data.never_fails:
if (100*randf()) > (data.accuracy * (user.get_effective_stats()[Stats.ACC] / opponent.get_effective_stats()[Stats.EVA])) and not data.never_fails:
battle_scene.move_failed()
var proceed = true
for e in data.fail_effect:
Expand All @@ -143,7 +145,7 @@ class OpMove:
return

# Checks if the move is effective
var effectiveness = TYPE_EFFECTIVENESS[data.type][opponent.species.type_1] * TYPE_EFFECTIVENESS[data.type][opponent.species.type_2]
var effectiveness = TYPE_EFFECTIVENESS[opponent.species.type_1][data.type] * TYPE_EFFECTIVENESS[data.type][opponent.species.type_2]
if effectiveness == 0.0:
battle_scene.effectiveness(effectiveness)
proceed = true
Expand Down
10 changes: 9 additions & 1 deletion Objects/OpTeam.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ func is_ko() -> bool:
if(opmon != null):
total = total and opmon.is_ko()
return total


# Returns the next non-ko OpMon available, null if the team is KO
func next_available() -> OpMon:
for opmon in _team:
if opmon != null:
if not opmon.is_ko():
return opmon
return null

# Switches two OpMons
func switch(index1: int, index2: int):
var op1 = _team[index1]
Expand Down
12 changes: 11 additions & 1 deletion Scenes/Battle/BaseDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ signal run_selected

const _signals = ["move_selected", "item_selected", "opmon_selected", "run_selected"]

var cooldown := 5

func _ready():
for s in _signals:
connect(s, get_parent(), s)
update_idle_dialog()

func update_idle_dialog():
$BigDialog/RichTextLabel.text = tr("BATTLE_BASEDIALOG_FILLER").replace("{opmon}",get_parent().player_opmon.get_effective_name())

func _process(_delta):
if cooldown > 0 and visible:
cooldown -= 1

func _input(event):
if self.visible:
if self.visible and cooldown == 0:
var olcur = _curpos
if event.is_action_pressed("ui_down") and _curpos % 2 == 0: # If down and in the upper part of box
_curpos += 1
Expand All @@ -28,5 +37,6 @@ func _input(event):
_curpos -= 2
elif event.is_action_pressed("ui_accept"):
emit_signal(_signals[_curpos])
cooldown = 5
if olcur != _curpos: # Update the position only if the position has changed
$SmallDialog/Arrow.rect_position = _positions[_curpos]
Loading