Move tool stuff to tool.{h,cpp}
[oweals/minetest.git] / src / tool.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "tool.h"
21
22 std::string tool_get_imagename(const std::string &toolname)
23 {
24         if(toolname == "WPick")
25                 return "tool_woodpick.png";
26         else if(toolname == "STPick")
27                 return "tool_stonepick.png";
28         else if(toolname == "SteelPick")
29                 return "tool_steelpick.png";
30         else if(toolname == "MesePick")
31                 return "tool_mesepick.png";
32         else if(toolname == "WShovel")
33                 return "tool_woodshovel.png";
34         else if(toolname == "STShovel")
35                 return "tool_stoneshovel.png";
36         else if(toolname == "SteelShovel")
37                 return "tool_steelshovel.png";
38         else if(toolname == "WAxe")
39                 return "tool_woodaxe.png";
40         else if(toolname == "STAxe")
41                 return "tool_stoneaxe.png";
42         else if(toolname == "SteelAxe")
43                 return "tool_steelaxe.png";
44         else if(toolname == "WSword")
45                 return "tool_woodsword.png";
46         else if(toolname == "STSword")
47                 return "tool_stonesword.png";
48         else if(toolname == "SteelSword")
49                 return "tool_steelsword.png";
50         else
51                 return "cloud.png";
52 }
53
54 ToolDiggingProperties tool_get_digging_properties(const std::string &toolname)
55 {
56         // weight, crackiness, crumbleness, cuttability
57         if(toolname == "WPick")
58                 return ToolDiggingProperties(2.0, 0,-1,2,0, 50, 0,0,0,0);
59         else if(toolname == "STPick")
60                 return ToolDiggingProperties(1.5, 0,-1,2,0, 100, 0,0,0,0);
61         else if(toolname == "SteelPick")
62                 return ToolDiggingProperties(1.0, 0,-1,2,0, 300, 0,0,0,0);
63
64         else if(toolname == "MesePick")
65                 return ToolDiggingProperties(0, 0,0,0,0, 1337, 0,0,0,0);
66         
67         else if(toolname == "WShovel")
68                 return ToolDiggingProperties(2.0, 0.5,2,-1.5,0.3, 50, 0,0,0,0);
69         else if(toolname == "STShovel")
70                 return ToolDiggingProperties(1.5, 0.5,2,-1.5,0.1, 100, 0,0,0,0);
71         else if(toolname == "SteelShovel")
72                 return ToolDiggingProperties(1.0, 0.5,2,-1.5,0.0, 300, 0,0,0,0);
73
74         // weight, crackiness, crumbleness, cuttability
75         else if(toolname == "WAxe")
76                 return ToolDiggingProperties(2.0, 0.5,-0.2,1,-0.5, 50, 0,0,0,0);
77         else if(toolname == "STAxe")
78                 return ToolDiggingProperties(1.5, 0.5,-0.2,1,-0.5, 100, 0,0,0,0);
79         else if(toolname == "SteelAxe")
80                 return ToolDiggingProperties(1.0, 0.5,-0.2,1,-0.5, 300, 0,0,0,0);
81
82         else if(toolname == "WSword")
83                 return ToolDiggingProperties(3.0, 3,0,1,-1, 50, 0,0,0,0);
84         else if(toolname == "STSword")
85                 return ToolDiggingProperties(2.5, 3,0,1,-1, 100, 0,0,0,0);
86         else if(toolname == "SteelSword")
87                 return ToolDiggingProperties(2.0, 3,0,1,-1, 300, 0,0,0,0);
88
89         // Properties of hand
90         return ToolDiggingProperties(0.5, 1,0,-1,0, 50, 0,0,0,0);
91 }
92
93