forked from NB-Core/lotgd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
masters.php
152 lines (145 loc) · 6.31 KB
/
masters.php
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
<?php
// Initially written as a module by Chris Vorndran.
// Moved into core by JT Traub
require_once("common.php");
require_once("lib/http.php");
check_su_access(SU_EDIT_CREATURES);
tlschema("masters");
$op = httpget('op');
$id = (int)httpget('id');
$act = httpget('act');
page_header("Masters Editor");
require_once("lib/superusernav.php");
superusernav();
if ($op == "del") {
$sql = "DELETE FROM " . db_prefix("masters") . " WHERE creatureid=$id";
db_query($sql);
output("`^Master deleted.`0");
$op = "";
httpset("op", "");
} elseif ($op == "save") {
$name = addslashes(httppost('name'));
$weapon = addslashes(httppost('weapon'));
$win = addslashes(httppost('win'));
$lose = addslashes(httppost('lose'));
$lev = (int)httppost('level');
if ($id != 0) {
$sql = "UPDATE " . db_prefix("masters") . " SET creaturelevel=$lev, creaturename='$name', creatureweapon='$weapon', creaturewin='$win', creaturelose='$lose' WHERE creatureid=$id";
} else {
$atk = $lev * 2;
$def = $lev * 2;
$hp = $lev*11;
if ($hp == 11) $hp++;
$sql = "INSERT INTO " . db_prefix("masters") . " (creatureid,creaturelevel,creaturename,creatureweapon,creaturewin,creaturelose,creaturehealth,creatureattack,creaturedefense) VALUES ($id,$lev,'$name', '$weapon', '$win', '$lose', '$hp', '$atk', '$def')";
}
db_query($sql);
if ($id == 0) {
output("`^Master %s`^ added.", stripslashes($name));
} else {
output("`^Master %s`^ updated.", stripslashes($name));
}
$op = "";
httpset("op", "");
} elseif ($op == "edit") {
addnav("Functions");
addnav("Return to Masters Editor", "masters.php");
$sql = "SELECT * FROM ".db_prefix("masters")." WHERE creatureid=$id";
$res = db_query($sql);
if (db_num_rows($res) == 0) {
$row = array(
'creaturelevel'=>1,
'creaturename'=>'',
'creatureweapon'=>'',
'creaturewin'=>'',
'creaturelose'=>''
);
} else {
$row = db_fetch_assoc($res);
}
addnav("","masters.php?op=save&id=$id");
rawoutput("<form action='masters.php?op=save&id=$id' method='POST'>");
output("`^Master's level:`n");
rawoutput("<select name='level'>");
$maxlevel=getsetting('maxlevel');
for ($i=0;$i<$maxlevel;$i++) {
$selected=($i==$row['creaturelevel']?' selected':'');
rawoutput("<option$selected>$i</option>");
}
rawoutput("</select>");
output_notl("`n");
output("`^Master's name:`n");
rawoutput("<input id='input' name='name' value='".htmlentities($row['creaturename'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."'>");
output_notl("`n");
output("`^Master's weapon:`n");
rawoutput("<input id='input' name='weapon' value='".htmlentities($row['creatureweapon'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."'>");
output_notl("`n");
output("`^Master's speech when player wins:`n");
rawoutput("<textarea name='lose' rows='5' cols='30' class='input'>".htmlentities($row['creaturelose'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."</textarea>");
output_notl("`n");
output("`^Master's speech when player loses:`n");
rawoutput("<textarea name='win' rows='5' cols='30' class='input'>".htmlentities($row['creaturewin'], ENT_COMPAT, getsetting("charset", "ISO-8859-1"))."</textarea>");
output_notl("`n");
$submit = translate_inline("Submit");
rawoutput("<input type='submit' class='button' value='$submit'>");
rawoutput("</form>");
output_notl("`n`n");
output("`#The following codes are supported in both the win and lose speeches (case matters):`n");
output("The following codes are supported (case matters):`n");
output("{goodguyname} = The player's name (also can be specified as {goodguy}`n");
output("{weaponname} = The player's weapon (also can be specified as {weapon}`n");
output("{armorname} = The player's armor (also can be specified as {armor}`n");
output("{himher} = Subjective pronoun for the player (him her)`n");
output("{hisher} = Possessive pronoun for the player (his her)`n");
output("{heshe} = Objective pronoun for the player (he she)`n");
output("{badguyname} = The monster's name (also can be specified as {badguy}`n");
output("{badguyweapon} = The monster's weapon (also can be specified as {creatureweapon}`n");
}
if ($op == "") {
addnav("Functions");
addnav("Refresh list", "masters.php");
addnav("Add master", "masters.php?op=edit&id=0");
$sql = "SELECT * FROM ".db_prefix("masters")." ORDER BY creaturelevel";
$res = db_query($sql);
$count = db_num_rows($res);
$ops = translate_inline("Ops");
$edit = translate_inline("edit");
$del = translate_inline("del");
$delconfirm = translate_inline("Are you sure you wish to delete this master.");
$name = translate_inline("Name");
$level = translate_inline ("Level");
$lose = translate_inline("Lose to Master");
$win = translate_inline("Win against Master");
$weapon = translate_inline("Weapon");
rawoutput("<table border='0' cellpadding='2' cellspacing='1' align='center' bgcolor='#999999'>");
rawoutput("<tr class='trhead'><td>$ops</td><td>$level</td><td>$name</td><td>$weapon</td><td>$win</td><td>$lose</tr>");
$i = false;
while ($row = db_fetch_assoc($res)) {
$id = $row['creatureid'];
rawoutput("<tr class='".($i?"trdark":"trlight")."'><td nowrap>");
rawoutput("[ <a href='masters.php?op=edit&id=$id'>");
output_notl($edit);
rawoutput("</a> | <a href='masters.php?op=del&id=$id' onClick='return confirm(\"$delconfirm\");'>");
output_notl($del);
rawoutput("] </a>");
addnav("","masters.php?op=edit&id=$id");
addnav("","masters.php?op=del&id=$id");
rawoutput("</td><td>");
output_notl("`%%s`0",$row['creaturelevel']);
rawoutput("</td><td>");
output_notl("`#%s`0",stripslashes($row['creaturename']));
rawoutput("</td><td>");
output_notl("`!%s`0",stripslashes($row['creatureweapon']));
rawoutput("</td><td>");
output_notl("`&%s`0",stripslashes($row['creaturelose']));
rawoutput("</td><td>");
output_notl("`^%s`0",stripslashes($row['creaturewin']));
rawoutput("</td></tr>");
$i=!$i;
}
rawoutput("</table>");
output("`n`#You can change the names, weapons and messages of all of the Training Masters.");
output("`n`3You can add masters up to the maximum level where the dragon appears in the forest and which can be set in your game settings -> game setup. You cannot assign higher masters, but if you choose not to make one master for each level, the earlier master will appear again to the player to test him.`n");
output("`# It is suggested, that you do not toy around with this, unless you know what you are doing.`0`n");
}
page_footer();
?>