-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcraft.cpp
More file actions
165 lines (143 loc) · 4.26 KB
/
craft.cpp
File metadata and controls
165 lines (143 loc) · 4.26 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "craft.h"
#include "alchemist/axe_blade.h"
#include "alchemist/axe_handle.h"
#include "alchemist/axe.h"
#include "alchemist/knife_blade.h"
#include "alchemist/knife_handle.h"
#include "alchemist/knife.h"
#include "player.h"
#include "text.h"
#include <cstdio>
extern class Player player;
extern int active_hotbar;
InventoryElement * craft_axe_blade()
{
InventoryElement * el = player.hotbar[active_hotbar];
if (el) {
sprintf(status_line, "crafting: axe blade from %s", el->get_name());
AxeBlade * axe_blade=new AxeBlade(el);
if (axe_blade->craft()) {
axe_blade->show();
axe_blade->set_posittion(player.x, player.y);
player.inventory->remove(el);
player.hotbar[active_hotbar]=NULL;
return axe_blade;
} else delete axe_blade;
}
return NULL;
}
InventoryElement * craft_axe_handle()
{
InventoryElement * el = player.hotbar[active_hotbar];
if (el) {
sprintf(status_line, "crafting: axe handle from %s", el->get_name());
AxeHandle * axe_handle=new AxeHandle(el);
if (axe_handle->craft())
{
axe_handle->show();
axe_handle->set_posittion(player.x, player.y);
player.inventory->remove(el);
player.hotbar[active_hotbar]=NULL;
return axe_handle;
} else delete axe_handle;
}
return NULL;
}
InventoryElement * craft_axe()
{
InventoryElement *el1=NULL, *el2=NULL;
for (int i =0; i< 10; i++)
{
if (player.craftbar[i])
{
player.craftbar[i]=0;
if (!el1) {
el1 = player.hotbar[i];
} else {
el2 = player.hotbar[i];
player.hotbar[i]=NULL;
break;
}
player.hotbar[i]=NULL;
}
}
if (el1 && el2)
{
sprintf(status_line, "crafting: axe from %s and %s", el1->get_name(), el2->get_name());
Axe * axe=new Axe(el1, el2);
if (axe->craft())
{
axe->show();
axe->set_posittion(player.x, player.y);
player.inventory->remove(el1);
player.inventory->remove(el2);
return axe;
} else delete axe;
}
return NULL;
}
InventoryElement * craft_knife_blade()
{
InventoryElement * el = player.hotbar[active_hotbar];
printf("FUN!\n");
if (el) {
sprintf(status_line, "crafting: knife blade from %s", el->get_name());
KnifeBlade * knife_blade=new KnifeBlade(el);
if (knife_blade->craft()) {
knife_blade->show();
knife_blade->set_posittion(player.x, player.y);
player.inventory->remove(el);
player.hotbar[active_hotbar]=NULL;
return knife_blade;
} else delete knife_blade;
}
return NULL;
}
InventoryElement * craft_knife_handle()
{
InventoryElement * el = player.hotbar[active_hotbar];
if (el) {
sprintf(status_line, "crafting: knife handle from %s", el->get_name());
KnifeHandle * knife_handle=new KnifeHandle(el);
if (knife_handle->craft()) {
knife_handle->show();
knife_handle->set_posittion(player.x, player.y);
player.inventory->remove(el);
player.hotbar[active_hotbar]=NULL;
return knife_handle;
} else delete knife_handle;
}
return NULL;
}
InventoryElement * craft_knife()
{
InventoryElement *el1=NULL, *el2=NULL;
for (int i =0; i< 10; i++)
{
if (player.craftbar[i])
{
player.craftbar[i]=0;
if (!el1) {
el1 = player.hotbar[i];
} else {
el2 = player.hotbar[i];
player.hotbar[i]=NULL;
break;
}
player.hotbar[i]=NULL;
}
}
if (el1 && el2)
{
sprintf(status_line, "crafting: knife from %s and %s", el1->get_name(), el2->get_name());
Knife * knife=new Knife(el1, el2);
if (knife->craft()) {
knife->show();
knife->set_posittion(player.x, player.y);
player.inventory->remove(el1);
player.inventory->remove(el2);
return knife;
} else delete knife;
}
return NULL;
}