craft objects





PHPXRef 0.7 : NEABExplorer : /skills/craft_objects.php source









[ Index ]


PHP Cross Reference of NEABExplorer














if (gwGetCookie('xrefnav')=='off')
document.write('[ Show Explorer ]');
else
document.write('[ Hide Explorer ]');



[ Show Explorer ]
[ Hide Navbar ]





titleBody[close]
/skills/ -> craft_objects.php (source)

[Summary view]
[Print]
[Text view]


1 <?PHP
2 /**
3 * Code used for the crafting skill.
4 * Crafting requires a blueprint.
5 */
6
7 echo "<BR><DIV ALIGN=CENTER>\n";
8 if($_GET["ACTION"] == "CREATE" && $_GET["ID"] != "")
9 {
10 $id=$_GET["ID"]+0;
11 $r=$db->Execute("SELECT COUNT(OBJECTID) FROM PLAYER_BLUEPRINTS WHERE USERID=$userid AND OBJECTID = $id");
12 $n=$r->fields[0]+0;
13 $r->Close();
14
15 if($n == 0)
16 {
17 echo "<B>You do not have this blueprint. Sorry.</B><BR>\n";
18 }
19 else
20 {
21 $r=$db->Execute("SELECT NBTIMES FROM PLAYER_BLUEPRINTS WHERE USERID=$userid AND OBJECTID = $id");
22 $nbprints=$r->fields[0]+0;
23 $r->Close();
24
25 $isok=true;
26 $nbtimes=$_GET["NBTIMES"]+0;
27 if($nbtimes > 20)
28 $nbtimes=20;
29 echo "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1 BGCOLOR=#000000 WIDTH=90%>";
30 echo "<TR><TH><B><FONT COLOR=#FFFFFF>Result</FONT></B></TH></TR>\n";
31 echo "<TR><TD BGCOLOR=#E0E0E0>";
32 echo "<DIV STYLE='width:100%; height:70; overflow:auto;'>";
33
34 $trial=0;
35 while($isok && $nbtimes > 0)
36 {
37 $nbtimes--;
38 $trial++;
39 $r=$db->Execute("SELECT NBITEMS,ITEM FROM OBJECT_FORMULA WHERE OBJECTID = $id AND TYPE = 'C'");
40 while(!$r->EOF)
41 {
42 if(inventory_check($r->fields[1]) < ($r->fields[0]+0))
43 {
44 $isok=false;
45 echo "Trial $trial: <B>Sorry... but you do not have the required materials to create this object.</B><BR>\n";
46 break;
47 }
48 $r->MoveNext();
49 }
50 $r->Close();
51 if($isok)
52 {
53 $r=$db->Execute("SELECT NBITEMS,ITEM FROM OBJECT_FORMULA WHERE OBJECTID = $id AND TYPE = 'C'");
54 while(!$r->EOF)
55 {
56 inventory_add($r->fields[1],-$r->fields[0]);
57 $r->MoveNext();
58 }
59 $r->Close();
60 $r=$db->Execute("SELECT PRICE FROM OBJECTS WHERE ID = $id");
61 $price=$r->fields[0]+0;
62 $r->Close();
63
64 //$prob=$uservals["DEXTERITY"]+$uservals["INTELLIGENCE"];
65 $prob=$uservals["DEXTERITY"]+$uservals["DEXMOD"]+$uservals["TEMP_DEX"]+$uservals["INTELLIGENCE"]+$uservals["INTMOD"]+$uservals["TEMP_INT"];
66 $perc=ceil($prob/ceil($price/160)*100);
67 if($perc > 100)
68 $perc=100;
69
70 $didit=false;
71 if($perc == 100 || mt_rand(0,100) < $perc)
72 {
73 inventory_add($id,1);
74 echo "Trial $trial: <B>You created the object !</B><BR>\n";
75 $didit=true;
76 }
77 else
78 {
79 echo "Trial $trial: <B><FONT COLOR=#E00000>You were unable to craft the item and lost all the raw materials used for it.</FONT></B><BR>\n";
80 }
81
82 if($nbprints >= 0 && $didit == true) // Decrease the counter for the number of times the player can still create this object.
83 {
84 $nbprints--;
85 if($nbprints <= 0)
86 {
87 $db->Execute("DELETE FROM PLAYER_BLUEPRINTS WHERE USERID=$userid AND OBJECTID = $id");
88 $isok=false;
89 }
90 else
91 $db->Execute("UPDATE PLAYER_BLUEPRINTS SET NBTIMES = $nbprints WHERE USERID=$userid AND OBJECTID = $id");
92 }
93 }
94 }
95 echo "</DIV></TD></TR></TABLE><BR>\n";
96 }
97 }
98 $prob=$uservals["DEXTERITY"]+$uservals["DEXMOD"]+$uservals["TEMP_DEX"]+$uservals["INTELLIGENCE"]+$uservals["INTMOD"]+$uservals["TEMP_INT"];
99 $sql="SELECT OBJECTS.ID,OBJECTS.NAME,OBJECTS.PRICE,PLAYER_BLUEPRINTS.NBTIMES FROM PLAYER_BLUEPRINTS,OBJECTS WHERE PLAYER_BLUEPRINTS.OBJECTID = OBJECTS.ID AND PLAYER_BLUEPRINTS.USERID=$userid";
100 $r=$db->Execute($sql);
101 if(!$r->EOF)
102 {
103 echo "<FORM METHOD=GET ACTION=game.php>\n";
104 echo "<INPUT TYPE=HIDDEN NAME=ACTION VALUE=CREATE>\n";
105 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 WIDTH=90% BGCOLOR=#000000 ALIGN=CENTER><TR><TD>";
106 echo "<TABLE BORDER=0 CELLSPACING=0 WIDTH=100% BGCOLOR=#E0E0E0>\n";
107 echo "<TR BGCOLOR=#000000><TD COLSPAN=4 ALIGN=CENTER><FONT COLOR=#FFFFFF><B>Known blueprints</B></FONT></TD></TR>\n";
108 echo "<TR BGCOLOR=#000000><TD>&nbsp;</TD>\n";
109 echo "<TD><B><FONT COLOR=#FFFFFF>Object</FONT></B></TD>\n";
110 echo "<TD><B><FONT COLOR=#FFFFFF>Probability</FONT></B></TD>\n";
111 echo "<TD><B><FONT COLOR=#FFFFFF>Material needed</FONT></B></TD></TR>\n";
112 while(!$r->EOF)
113 {
114 echo "<TR VALIGN=TOP>";
115 //echo "<TD>[<A HREF=game.php?ACTION=CREATE&ID=".$r->fields[0].">Create</A>]</TD>\n";
116 echo "<TD><INPUT TYPE=RADIO NAME=ID VALUE=".$r->fields[0]."></TD>\n";
117 if(($r->fields[3]+0) > 0)
118 echo "<TD>".$r->fields[1]." (".$r->fields[3].")</TD>\n";
119 else
120 echo "<TD>".$r->fields[1]."</TD>\n";
121 $perc=ceil($prob/ceil($r->fields[2]/160)*100);
122 if($perc > 100)
123 $perc=100;
124 echo "<TD>".$perc."%</TD>\n";
125 echo "<TD>";
126 $sql="SELECT OBJECT_FORMULA.NBITEMS,OBJECTS.NAME,OBJECT_FORMULA.ITEM FROM OBJECT_FORMULA,OBJECTS WHERE
127 OBJECTS.ID = OBJECT_FORMULA.ITEM AND OBJECT_FORMULA.OBJECTID = ".$r->fields[0];
128 $r2=$db->Execute($sql);
129 $first=true;
130 while(!$r2->EOF)
131 {
132 if(!$first)
133 echo ", ";
134 $r3=$db->Execute("SELECT NBITEMS FROM INVENTORY WHERE USERID=$userid AND OBJECTID=".$r2->fields[2]);
135 if(($r3->fields[0]+0) < ($r2->fields[0]+0))
136 echo "<FONT COLOR=#E00000><B>";
137 echo "(".$r2->fields[0]." / ".($r3->fields[0]+0).") ".$r2->fields[1];
138 if(($r3->fields[0]+0) < ($r2->fields[0]+0))
139 echo "</B></FONT>";
140 $r3->Close();
141 $r2->MoveNext();
142 $first=false;
143 }
144 $r2->Close();
145 echo "</TD>";
146 echo "</TR>\n";
147 $r->MoveNext();
148 }
149 echo "<TR BGCOLOR=#A0A0A0><TD COLSPAN=2>&nbsp;<B>Number of trials (max 20):</B></TD><TD COLSPAN=2><INPUT TYPE=TEXT NAME=NBTIMES VALUE=1 SIZE=4></TD></TR>\n";
150 echo "</TABLE></TD></TR></TABLE><BR>\n";
151 echo "[<A HREF=# OnClick='document.forms[0].submit();return false'>Craft</A>]\n";
152 }
153 else
154 {
155 echo "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 BGCOLOR=#000000 WIDTH=90%>";
156 echo "<TR><TH><B><FONT COLOR=#FFFFFF>Known blueprints</FONT></B></TH></TR>\n";
157 echo "<TR><TD BGCOLOR=#E0E0E0>";
158 echo "You don't have any blueprints at the moment.\n";
159 echo "</TD></TR></TABLE><BR>\n";
160 }
161 $r->Close();
162 echo "[<A HREF=game.php?PHPCODE=NONE>Cancel</A>]\n";
163 echo "</DIV>\n";
164 ?>



FUNC_DATA={
'movenext': ['movenext', '', [['libs','db_conn_5.php',89],['libs','db_conn_4.php',89]], 104],
'inventory_add': ['inventory_add', 'Adds an item to the inventory. (no message) ', [['libs','objects_util.php',359]], 49],
'close': ['close', '', [['libs','db_conn_5.php',35],['libs','db_conn_5.php',87],['libs','db_conn_4.php',35],['libs','db_conn_4.php',87]], 380],
'inventory_check': ['inventory_check', 'Checks if the player have this item. ', [['libs','objects_util.php',425]], 44],
'execute': ['execute', '', [['libs','db_conn_5.php',37],['libs','db_conn_4.php',37]], 652],
'mt_rand': ['mt_rand', '', [], 102],
'count': ['count', '', [], 113],
'ceil': ['ceil', '', [], 66]};
CLASS_DATA={
};
CONST_DATA={
};

titleDescriptionBody
titleDescriptionBody
titleDescriptionBody
titleBody



Generated: Sun Jul 8 18:11:25 2007
Cross-referenced by PHPXref 0.7





Wyszukiwarka

Podobne podstrony:
craft objects
craft objects
stream writer objects
ObjectImpl
function hwapi object remove
110 Amazing Magic Tricks With Everyday Objects
function pg fetch object
Object
subject object questions
Object
bltin code objects
PrettyPrinter Objects
content handler objects
ObjectStreamField
pleasure craft information packdec07 2
hand craft edearrings
event objects

więcej podobnych podstron