7 new revisions:
Revision: 3d04ed7936
Author:
tvsd...@gmail.com
Date: Thu Sep 3 09:55:56 2009
Log: Добавлена таблица для хранения записей о надетых на игрока вещах.
http://code.google.com/p/endspiel/source/detail?r=3d04ed7936
Revision: ea7a5c2d3c
Author:
tvsd...@gmail.com
Date: Thu Sep 3 09:59:28 2009
Log: Исправлена ошибка в тексте SQL.
http://code.google.com/p/endspiel/source/detail?r=ea7a5c2d3c
Revision: b4a987250a
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:54:07 2009
Log: Добавлены строки по экипировке персонажа
http://code.google.com/p/endspiel/source/detail?r=b4a987250a
Revision: 9420b344ce
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:54:28 2009
Log: Добавлен шаблон страницы экипировки
http://code.google.com/p/endspiel/source/detail?r=9420b344ce
Revision: 7af41bcddf
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:56:01 2009
Log: Шаблон перестроен на использование унифицированной базы локали.
http://code.google.com/p/endspiel/source/detail?r=7af41bcddf
Revision: f48e1f0150
Author:
tvsd...@gmail.com
Date: Thu Sep 3 11:07:44 2009
Log: Изменен тип данных для поля слота (wearing) таблицы шаблонов вещей.
http://code.google.com/p/endspiel/source/detail?r=f48e1f0150
Revision: e8941d60a3
Author:
tvsd...@gmail.com
Date: Thu Sep 3 11:09:48 2009
Log: Значительные добавления для реализации подсистемы ношения вещей.
Вещи ...
http://code.google.com/p/endspiel/source/detail?r=e8941d60a3
==============================================================================
Revision: 3d04ed7936
Author:
tvsd...@gmail.com
Date: Thu Sep 3 09:55:56 2009
Log: Добавлена таблица для хранения записей о надетых на игрока вещах.
http://code.google.com/p/endspiel/source/detail?r=3d04ed7936
Modified:
/install.sql
=======================================
--- /install.sql Mon Aug 31 09:47:39 2009
+++ /install.sql Thu Sep 3 09:55:56 2009
@@ -76,6 +76,16 @@
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `equipment`
+
+CREATE TABLE IF NOT EXISTS `equipment`(
+ `userid` int(11) NOT NULL,
+ `slot` int(11) NOT NULL,
+ `itemid` int(11) NOT NULL,
+ PRIMARY KEY (`userid`, `slot`),
+ UNIQUE KEY (`itemid`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
DROP TABLE IF EXISTS `map`;
CREATE TABLE IF NOT EXISTS `map`(
==============================================================================
Revision: ea7a5c2d3c
Author:
tvsd...@gmail.com
Date: Thu Sep 3 09:59:28 2009
Log: Исправлена ошибка в тексте SQL.
http://code.google.com/p/endspiel/source/detail?r=ea7a5c2d3c
Modified:
/install.sql
=======================================
--- /install.sql Thu Sep 3 09:55:56 2009
+++ /install.sql Thu Sep 3 09:59:28 2009
@@ -76,7 +76,7 @@
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-DROP TABLE IF EXISTS `equipment`
+DROP TABLE IF EXISTS `equipment`;
CREATE TABLE IF NOT EXISTS `equipment`(
`userid` int(11) NOT NULL,
==============================================================================
Revision: b4a987250a
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:54:07 2009
Log: Добавлены строки по экипировке персонажа
http://code.google.com/p/endspiel/source/detail?r=b4a987250a
Modified:
/lib/str.php
=======================================
--- /lib/str.php Mon Aug 31 09:50:22 2009
+++ /lib/str.php Thu Sep 3 10:54:07 2009
@@ -43,6 +43,20 @@
'close' => 'Закрыть',
'equipment' => 'Обмундирование',
+ 'wear' => 'Надеть',
+ 'takeoff' => 'Убрать',
+ 'take' => 'Взять',
+ 'throw' => 'Выбросить',
+
+ 'head' => 'Шлем',
+ 'body' => 'Броня',
+ 'leftarm' => 'Левая рука',
+ 'rightarm' => 'Правая рука',
+ 'arms' => 'Перчатки',
+ 'belt' => 'Пояс',
+ 'legs' => 'Штаны',
+ 'foot' => 'Обувь',
+
'PDA' => 'PDA',
'map' => 'Карта',
'top' => 'Рейтинг',
==============================================================================
Revision: 9420b344ce
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:54:28 2009
Log: Добавлен шаблон страницы экипировки
http://code.google.com/p/endspiel/source/detail?r=9420b344ce
Added:
/tpl/tpl/base.equipment.tpl
=======================================
--- /dev/null
+++ /tpl/tpl/base.equipment.tpl Thu Sep 3 10:54:28 2009
@@ -0,0 +1,68 @@
+{* Smarty *}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="
http://www.w3.org/1999/xhtml" dir="ltr" lang="{$str.locale}">
+<head>
+ <title>{$title}</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <link rel="stylesheet" href="/css/base.css" media="all" />
+</head>
+<body>
+ <div class="cwrap">
+ {include file='base.include.exitbtn.tpl'}
+ <h4>{$str.equipment}</h4>
+ <table>
+ <tr>
+ <td>
+ <form action="/" method="POST">
+ <input type="hidden" name="m" value="idle" />
+ <input type="submit" value="{$str.close}" />
+ </form>
+ </td>
+ <td>
+ <form action="/" method="POST">
+ <input type="hidden" name="m" value="bag" />
+ <input type="submit" value="{$str.bag}" />
+ </form>
+ </td>
+ </tr>
+ </table>
+ <table>
+ {foreach from=$items item=i}
+ <tr>
+ <td class="alef">
+ <b>
+ {if $i.slot == 1}
+ {$str.head}:
+ {elseif $i.slot == 2}
+ {$str.body}:
+ {elseif $i.slot == 3}
+ {$str.leftarm}:
+ {elseif $i.slot == 4}
+ {$str.rightarm}:
+ {elseif $i.slot == 5}
+ {$str.arms}:
+ {elseif $i.slot == 6}
+ {$str.belt}:
+ {elseif $i.slot == 7}
+ {$str.legs}:
+ {elseif $i.slot == 8}
+ {$str.foot}:
+ {/if}
+ </b>
+ </td>
+ <td class="alef">
+ {$i.title}
+ </td>
+ <td class="alef">
+ <form action="/" method="POST">
+ <input type="hidden" name="m" value="bag" />
+ <input type="hidden" name="d" value="takeoff" />
+ <input type="hidden" name="i" value="{$i.slot}" />
+ <input type="submit" value="{$str.takeoff}" />
+ </form>
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+ </div>
+</body>
==============================================================================
Revision: 7af41bcddf
Author:
tvsd...@gmail.com
Date: Thu Sep 3 10:56:01 2009
Log: Шаблон перестроен на использование унифицированной базы локали.
http://code.google.com/p/endspiel/source/detail?r=7af41bcddf
Modified:
/tpl/tpl/base.bag.tpl
=======================================
--- /tpl/tpl/base.bag.tpl Mon Aug 31 09:50:22 2009
+++ /tpl/tpl/base.bag.tpl Thu Sep 3 10:56:01 2009
@@ -35,10 +35,14 @@
</td>
<td class="alef">
<form action="/" method="POST">
- <input type="hidden" name="m" value="pda" />
- <input type="hidden" name="d" value="msgread" />
- <input type="hidden" name="i" value="{$
m.id}" />
- <input type="submit" value="Надеть" />
+ <input type="hidden" name="m" value="bag" />
+ <input type="hidden" name="d" value="wear" />
+ <input type="hidden" name="i" value="{$
i.id}" />
+ {if $i.type == 0}
+ <input type="submit" value="{$str.wear}" />
+ {elseif $i.type == 1}
+ <input type="submit" value="{$str.take}" />
+ {/if}
</form>
</td>
<td class="alef">
@@ -46,7 +50,7 @@
<input type="hidden" name="m" value="bag" />
<input type="hidden" name="d" value="throw" />
<input type="hidden" name="i" value="{$
i.id}" />
- <input type="submit" value="Выбросить" />
+ <input type="submit" value="{$str.throw}" />
</form>
</td>
</tr>
==============================================================================
Revision: f48e1f0150
Author:
tvsd...@gmail.com
Date: Thu Sep 3 11:07:44 2009
Log: Изменен тип данных для поля слота (wearing) таблицы шаблонов вещей.
http://code.google.com/p/endspiel/source/detail?r=f48e1f0150
Modified:
/install.sql
=======================================
--- /install.sql Thu Sep 3 09:59:28 2009
+++ /install.sql Thu Sep 3 11:07:44 2009
@@ -215,7 +215,7 @@
`title` varchar(255) NOT NULL,
`description` TEXT DEFAULT '',
`type` INT(11) NOT NULL,
- `wearing` BIT (16) NOT NULL DEFAULT 0,
+ `wearing` int(11) NOT NULL DEFAULT 0,
`basecost` FLOAT DEFAULT NULL,
`quality` FLOAT DEFAULT NULL,
`ammunition_type` INT(11) NOT NULL DEFAULT 0,
==============================================================================
Revision: e8941d60a3
Author:
tvsd...@gmail.com
Date: Thu Sep 3 11:09:48 2009
Log: Значительные добавления для реализации подсистемы ношения вещей. Вещи
можно одевать/снимать, подбирать/выбрасывать, одетые вещи не отображаются в
инвентаре etc.
http://code.google.com/p/endspiel/source/detail?r=e8941d60a3
Modified:
/lib/c.idle.class.php
/lib/inventory.class.php
=======================================
--- /lib/c.idle.class.php Mon Aug 31 09:50:22 2009
+++ /lib/c.idle.class.php Thu Sep 3 11:09:48 2009
@@ -141,12 +141,32 @@
case "throw":
{
Engine::get()->inventory->dropItem($_POST['i']);
+ $this->renderBagPage();
+ break;
+ }
+ case "equip":
+ {
+ $this->renderEquipmentPage();
+ break;
+ }
+ case "wear":
+ {
+ if (Engine::get()->inventory->isItemInBag($_POST['i']))
+ {
+ Engine::get()->inventory->wearItem($_POST['i']);
+ }
+ $this->renderBagPage();
+ break;
+ }
+ case "takeoff":
+ {
+ Engine::get()->inventory->takeOffItem($_POST['i']);
+ $this->renderEquipmentPage();
+ break;
}
default:
{
- $items = Engine::get()->inventory->listItems();
- Engine::get()->smarty->assign('items',$items);
- Engine::get()->smarty->display('base.bag.tpl'); //Генерация страницы
+ $this->renderBagPage();
}
}
break;
@@ -177,6 +197,20 @@
}
}
}
+
+ protected function renderBagPage()
+ {
+ $items = Engine::get()->inventory->listItems();
+ Engine::get()->smarty->assign('items',$items);
+ Engine::get()->smarty->display('base.bag.tpl'); //Генерация страницы
+ }
+
+ protected function renderEquipmentPage()
+ {
+ $items = Engine::get()->inventory->getWearedItems();
+ Engine::get()->smarty->assign('items',$items);
+ Engine::get()->smarty->display('base.equipment.tpl'); //Генерация
страницы
+ }
protected function renderIdlePage()
{
=======================================
--- /lib/inventory.class.php Mon Aug 31 09:45:34 2009
+++ /lib/inventory.class.php Thu Sep 3 11:09:48 2009
@@ -58,11 +58,53 @@
public function listItems()
{
- $stmt = Engine::get()->db->prepare('SELECT i.`id`, t.`title`,
t.`description` FROM `items` AS i LEFT JOIN `item_types` AS t ON t.`id` =
i.`itype` WHERE i.`owner` = :id;');
+ $stmt = Engine::get()->db->prepare('SELECT i.`id`, t.`title`,
t.`description`, t.`type`, t.`wearing` FROM `items` AS i LEFT JOIN
`item_types` AS t ON t.`id` = i.`itype` WHERE i.`owner` = :id AND i.`id`
NOT IN (SELECT `itemid` FROM `equipment`);');
$stmt->bindValue('id',$this->id);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
+
+ public function isItemInBag($itemid)
+ {
+ $stmt = Engine::get()->db->prepare('SELECT COUNT(*) FROM `items` WHERE
`id` = :itemid AND `owner` = :id;');
+ $stmt->bindValue('itemid',$itemid);
+ $stmt->bindValue('id',$this->id);
+ $stmt->execute();
+ return $stmt->fetchColumn() != 0;
+ }
+
+ public function wearItem($itemid)
+ {
+ $stmt = Engine::get()->db->prepare('INSERT INTO `equipment` (`userid`,
`slot`, `itemid`) SELECT i.`owner`, t.`wearing`, i.`id` FROM `items` AS i
LEFT JOIN `item_types` AS t ON t.`id` = i.`itype` WHERE i.`id` = :itemid ON
DUPLICATE KEY UPDATE `itemid` = :itemid;');
+ $stmt->bindValue(':itemid',$itemid);
+ $stmt->execute();
+ }
+
+ public function takeOffItem($slot)
+ {
+ $stmt = Engine::get()->db->prepare('UPDATE `equipment` SET `itemid` = 0
WHERE `userid` = :id AND `slot` = :slot LIMIT 1;');
+ $stmt->bindValue(':id', $this->id);
+ $stmt->bindValue(':slot', $slot);
+ $stmt->execute();
+ }
+
+ public function getWearedItems()
+ {
+ $stmt = Engine::get()->db->prepare('SELECT e.`slot`, e.`itemid` AS id,
t.`title` FROM `equipment` AS e LEFT JOIN `items` AS i ON i.`id` =
e.`itemid` LEFT JOIN `item_types` AS t ON t.`id` = i.`itype` WHERE
e.`userid` = :id;');
+ $stmt->bindValue(':id', $this->id);
+ $stmt->execute();
+ $items_raw = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ $items = array();
+ foreach ($items_raw as $i)
+ {
+ if ($i['id'] != 0)
+ {
+ $items[$i['slot']] = $i;
+ }
+ }
+ return $items;
+ }
+
}
?>