[UPDATE] Adding monster looks to db (#220)

* [UPDATE] Adding monster looks to db

* small adjustments

add into schema.sql + change position in table

* add DEFAULT = ''

---------

Co-authored-by: slawkens <slawkens@gmail.com>
This commit is contained in:
Matheus Collier 2023-03-31 04:04:13 -03:00 committed by GitHub
parent 7569536d56
commit fd419076c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 2 deletions

View File

@ -27,7 +27,7 @@ if (version_compare(phpversion(), '7.2.5', '<')) die('PHP version 7.2.5 or highe
const MYAAC = true;
const MYAAC_VERSION = '0.9.0-dev';
const DATABASE_VERSION = 34;
const DATABASE_VERSION = 35;
const TABLE_PREFIX = 'myaac_';
define('START_TIME', microtime(true));
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));

View File

@ -1,4 +1,4 @@
SET @myaac_database_version = 34;
SET @myaac_database_version = 35;
CREATE TABLE `myaac_account_actions`
(
@ -203,6 +203,7 @@ CREATE TABLE `myaac_monsters` (
`mana` int(11) NOT NULL DEFAULT 0,
`exp` int(11) NOT NULL,
`health` int(11) NOT NULL,
`look` VARCHAR(255) NOT NULL DEFAULT '',
`speed_lvl` int(11) NOT NULL default 1,
`use_haste` tinyint(1) NOT NULL,
`voices` text NOT NULL,

View File

@ -82,6 +82,9 @@ class Creatures {
$armor = $monster->getArmor();
$defensev = $monster->getDefense();
//load look
$look = $monster->getLook();
//load monster flags
$flags = $monster->getFlags();
if(!isset($flags['summonable']))
@ -147,6 +150,7 @@ class Creatures {
'armor' => $armor,
'race' => $race,
'loot' => json_encode($loot),
'look' => json_encode($look),
'summons' => json_encode($summons)
));

View File

@ -36,6 +36,7 @@
* @property-read int $armor Armor rate.
* @property-read array $defenses List of defenses.
* @property-read array $attacks List of attacks.
* @property-read array $look List of looks.
*/
class OTS_Monster extends DOMDocument
{
@ -273,6 +274,30 @@ class OTS_Monster extends DOMDocument
return $loot;
}
/**
* Returns look of the monster.
*
* @return array Look with all the attributes of the look.
* @throws DOMException On DOM operation error.
*/
public function getLook()
{
$look = array();
$element = $this->documentElement->getElementsByTagName('look')->item(0);
$look['type'] = $element->getAttribute('type');
$look['typeex'] = $element->getAttribute('typeex');
$look['head'] = $element->getAttribute('head');
$look['body'] = $element->getAttribute('body');
$look['legs'] = $element->getAttribute('legs');
$look['feet'] = $element->getAttribute('feet');
$look['addons'] = $element->getAttribute('addons');
$look['corpse'] = $element->getAttribute('corpse');
return $look;
}
/**
* Returns all monster summons.
*
@ -560,6 +585,9 @@ class OTS_Monster extends DOMDocument
case 'attacks':
return $this->getAttacks();
case 'look':
return $this->getLook();
default:
throw new OutOfBoundsException();
}

3
system/migrations/35.php Normal file
View File

@ -0,0 +1,3 @@
<?php
// add look column
$db->exec('ALTER TABLE `' . TABLE_PREFIX . "monsters` ADD `look` VARCHAR(255) NOT NULL DEFAULT '' AFTER `health`;");