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

Feature/762 pp up #763

Open
wants to merge 6 commits into
base: master
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
5 changes: 5 additions & 0 deletions pokedex/moves.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function M.get_move_pp(move)
return move and move.PP or 0
end

function M.get_move_max_pp_boost(move)
local pp = M.get_move_pp(move)
return pp and pp or 0
end

function M.get_known_to_all_moves()
return known_to_all_moves
end
Expand Down
39 changes: 36 additions & 3 deletions pokedex/pokemon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,22 @@ function M.remove_feat(pkmn, position)
end


function M.remove_move(pkmn, index)
function M.get_move_at_index(pkmn, index)
for move, data in pairs(M.get_moves(pkmn)) do
if index == data.index then
pkmn.moves[move] = nil
break
return move
end
end
return nil
end


function M.remove_move(pkmn, index)
local move = M.get_move_at_index(pkmn, index)
if move then
M.reset_move_pp_boost(pkmn, move)
pkmn.moves[move] = nil
end
end


Expand Down Expand Up @@ -548,6 +557,7 @@ function M.set_move(pkmn, new_move, index)
for name, move in pairs(M.get_moves(pkmn)) do
if move.index == index then
pkmn.moves[name] = nil
M.reset_move_pp_boost(pkmn, name)
pkmn.moves[new_move] = {pp=pp, index=index}
return
end
Expand Down Expand Up @@ -735,13 +745,36 @@ function M.get_move_pp(pkmn, move)
end


function M.get_move_pp_boost(pkmn, move)
if pkmn.pp_boost and pkmn.pp_boost[move] then
return pkmn.pp_boost[move]
end
return 0
end


function M.set_move_pp_boost(pkmn, move, boost)
if not pkmn.pp_boost then
pkmn.pp_boost = {}
end
boost = math.min(math.max(0, boost), movedex.get_move_max_pp_boost(move))
pkmn.pp_boost[move] = (boost > 0) and boost or nil
end


function M.reset_move_pp_boost(pkmn, move)
M.set_move_pp_boost(pkmn, move, 0)
end


function M.get_move_pp_max(pkmn, move)
local move_pp = movedex.get_move_pp(move)
if type(move_pp) == "string" then
-- probably move with Unlimited uses, i.e. Struggle
return move_pp
else
local _, pp_extra = M.have_feat(pkmn, "Tireless")
pp_extra = pp_extra + M.get_move_pp_boost(pkmn, move)
return movedex.get_move_pp(move) + pp_extra
end
end
Expand Down
185 changes: 179 additions & 6 deletions screens/change_pokemon/add/add.gui
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ nodes {
}
nodes {
position {
x: -160.0
x: 0.0
y: -85.0
z: 0.0
w: 1.0
Expand Down Expand Up @@ -959,7 +959,7 @@ nodes {
w: 1.0
}
size {
x: 300.0
x: 600.0
y: 70.0
z: 0.0
w: 1.0
Expand Down Expand Up @@ -996,7 +996,7 @@ nodes {
}
nodes {
position {
x: 6.0
x: -244.0
y: 4.0
z: 0.0
w: 1.0
Expand Down Expand Up @@ -1033,7 +1033,7 @@ nodes {
id: "change_pokemon/txt_move"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
pivot: PIVOT_W
outline {
x: 0.0
y: 0.0
Expand All @@ -1060,7 +1060,7 @@ nodes {
}
nodes {
position {
x: 152.0
x: 302.0
y: 4.0
z: 0.0
w: 1.0
Expand Down Expand Up @@ -1115,7 +1115,7 @@ nodes {
}
nodes {
position {
x: -121.0
x: -263.0
y: 3.0
z: 0.0
w: 1.0
Expand Down Expand Up @@ -1168,6 +1168,179 @@ nodes {
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 180.0
y: 4.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.8
y: 0.8
z: 0.6
w: 1.0
}
size {
x: 110.0
y: 45.0
z: 0.0
w: 1.0
}
color {
x: 0.7607843
y: 0.62352943
z: 0.5568628
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "PP +99"
font: "script_bold"
id: "change_pokemon/txt_move_pp"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "change_pokemon/btn_move"
layer: "script_bold"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 1.0
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 110.0
y: 4.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 44.0
y: 44.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "gui/minus_up"
id: "change_pokemon/btn_move_minus"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "change_pokemon/btn_move"
layer: "gui"
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 250.0
y: 4.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 44.0
y: 44.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "gui/plus_up"
id: "change_pokemon/btn_move_plus"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "change_pokemon/btn_move"
layer: "gui"
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -30.0
Expand Down
Loading