forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_equipitem.cpp
91 lines (80 loc) · 2.45 KB
/
window_equipitem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
// Headers
#include "window_equipitem.h"
#include "game_actors.h"
#include "game_party.h"
#include <lcf/reader_util.h>
#include "output.h"
Window_EquipItem::Window_EquipItem(int ix, int iy, int iwidth, int iheight, const Game_Actor& actor, int equip_type) :
Window_Item(ix, iy, iwidth, iheight),
actor(actor) {
this->equip_type = equip_type;
if (equip_type > 4 || equip_type < 0) {
this->equip_type = Window_EquipItem::other;
}
if (this->equip_type == Window_EquipItem::shield &&
actor.HasTwoWeapons()) {
this->equip_type = Window_EquipItem::weapon;
}
}
bool Window_EquipItem::CheckInclude(int item_id) {
// Do not show equippable items if the actor has its equipment fixed
if (actor.IsEquipmentFixed(false)) {
return false;
}
// Add the empty element
if (item_id == 0) {
return true;
}
bool result = false;
// Equipment and items are guaranteed to be valid
lcf::rpg::Item* item = lcf::ReaderUtil::GetElement(lcf::Data::items, item_id);
switch (equip_type) {
case Window_EquipItem::weapon:
result = item->type == lcf::rpg::Item::Type_weapon;
break;
case Window_EquipItem::shield:
result = item->type == lcf::rpg::Item::Type_shield;
break;
case Window_EquipItem::armor:
result = item->type == lcf::rpg::Item::Type_armor;
break;
case Window_EquipItem::helmet:
result = item->type == lcf::rpg::Item::Type_helmet;
break;
case Window_EquipItem::other:
result = item->type == lcf::rpg::Item::Type_accessory;
break;
default:
return false;
}
if (result) {
// Check if the party has the item at least once
if (Main_Data::game_party->GetItemCount(item_id) == 0) {
return false;
} else {
return actor.IsEquippable(item_id);
}
} else {
return false;
}
}
bool Window_EquipItem::CheckEnable(int item_id) {
(void)item_id;
return true;
}