From 555fef35c7bb75fc0de4459c66046e1943f765ce Mon Sep 17 00:00:00 2001 From: Lisa Riggle Date: Thu, 28 Dec 2017 22:08:34 -0600 Subject: [PATCH 1/3] Making a lot of changes so that more fields are random/dynamically generated. Changes to be committed: modified: app/Helpers/common.php modified: app/Models/Armor.php modified: app/Models/GameObject.php modified: app/Models/Jewelry.php modified: app/Traits/Wearable.php modified: config/icons.php modified: config/mana-usage.php new file: config/protection.php new file: config/tiers.php new file: config/type.php modified: database/migrations/2017_12_09_224942_CreateJewelryTable.php modified: database/migrations/2017_12_09_225241_CreateArmorTable.php modified: database/migrations/2017_12_09_225246_CreateWeaponTable.php modified: resources/views/armor.twig modified: resources/views/components/add-spells.twig --- app/Helpers/common.php | 20 ++++ app/Models/Armor.php | 109 +++++++++++++++--- app/Models/GameObject.php | 3 +- app/Models/Jewelry.php | 51 ++++++-- app/Traits/Wearable.php | 10 ++ config/icons.php | 30 ++++- config/mana-usage.php | 2 +- config/protection.php | 42 +++++++ config/tiers.php | 28 +++++ config/type.php | 24 ++++ .../2017_12_09_224942_CreateJewelryTable.php | 2 +- .../2017_12_09_225241_CreateArmorTable.php | 2 +- .../2017_12_09_225246_CreateWeaponTable.php | 2 +- resources/views/armor.twig | 19 +-- resources/views/components/add-spells.twig | 4 - 15 files changed, 298 insertions(+), 50 deletions(-) create mode 100644 config/protection.php create mode 100644 config/tiers.php create mode 100644 config/type.php diff --git a/app/Helpers/common.php b/app/Helpers/common.php index dcbebfd..c778585 100644 --- a/app/Helpers/common.php +++ b/app/Helpers/common.php @@ -19,3 +19,23 @@ function current_route() return Route::getCurrentRoute(); } } + +if ( !function_exists( 'rand_float' ) ) { + /** + * @param int $min + * @param int $max + * @param int $decimalPlaces + * + * @return float|int + */ + function rand_float( $min = 0, $max = 1, $decimalPlaces = 1 ) + { + $decimal = '.'; + for ( $i = 0; $i < $places - 1; $i++ ) { + $decimal .= '0'; + } + $decimal .= '1'; + + return rand( $min, $max ) * $decimal; + } +} diff --git a/app/Models/Armor.php b/app/Models/Armor.php index 41e1771..92f6ae5 100644 --- a/app/Models/Armor.php +++ b/app/Models/Armor.php @@ -72,7 +72,6 @@ class Armor extends GameObject protected $defaults = [ 'int' => [ '16' => 1, //Always Usable - '18' => 1, //UI Effects '27' => 8, //Armor Type??? '53' => 101, //Placement Position '93' => 1044, //Physics State @@ -125,32 +124,93 @@ public function mapData( Request $request ) $this->setAttribute( 'weenieType', array_get( $this->stats, $this->type . '.weenieType' ) ); //Set the item type - $this->stats[ $this->type ][ 'int' ][ '1' ] = config( $this->configKey( 'item-type' ) . '.id' ); + $this->defaults[ 'int' ][ '1' ] = config( $this->configKey( 'item-type' ) . '.id' ); //Clothing Priority - $this->stats[ $this->type ][ 'int' ][ '4' ] = config( $this->configKey( 'clothing-priority' ) . '.id' ); + $this->defaults[ 'int' ][ '4' ] = config( $this->configKey( 'clothing-priority' ) . '.id' ); //Set the body location - $this->stats[ $this->type ][ 'int' ][ '9' ] = config( $this->configKey( 'body-location' ) . '.id' ); + $this->defaults[ 'int' ][ '9' ] = config( $this->configKey( 'body-location' ) . '.id' ); - //Item Workmanship - $this->stats[ $this->type ][ 'int' ][ '105' ] = rand( 1, 10 ); + //UI Effects + $this->defaults[ 'int' ][ '18' ] = 0; + + //Pyreal Value + $this->defaults[ 'int' ][ '19' ] = rand( + config( $this->configKey( 'pyreal-value' ) . '.min' ), + config( $this->configKey( 'pyreal-value' ) . '.max' ) + ); + + //Armor Level + $this->defaults[ 'int' ][ '28' ] = rand( + config( $this->configKey( 'armor-level' ) . '.min' ), + config( $this->configKey( 'armor-level' ) . '.max' ) + ); //Bonded if ( !$request->has( 'int.33' ) ) { - $this->stats[ $this->type ][ 'int' ][ '33' ] = 0; + $this->defaults[ 'int' ][ '33' ] = 0; } + //Item Workmanship + $this->defaults[ 'int' ][ '105' ] = rand( + config( $this->configKey( 'workmanship' ) . '.min' ), + config( $this->configKey( 'workmanship' ) . '.max' ) + ); + //Attuned if ( !$request->has( 'int.114' ) ) { - $this->stats[ $this->type ][ 'int' ][ '114' ] = 0; + $this->defaults[ 'int' ][ '114' ] = 0; } - $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); - $this->setAttribute( 'bool', $this->addDefaults( 'bool' ) ); - $this->setAttribute( 'float', $this->addDefaults( 'float' ) ); - $this->setAttribute( 'did', $this->addDefaults( 'did' ) ); - $this->setAttribute( 'string', $this->addDefaults( 'string' ) ); + //Slashing Protection + $this->defaults[ 'float' ][ '13' ] = rand( + config( 'protection.slashing.min' ), + config( 'protection.slashing.max' ) + ); + + //Piercing Protection + $this->defaults[ 'float' ][ '14' ] = rand( + config( 'protection.piercing.min' ), + config( 'protection.piercing.max' ) + ); + + //Bludgeoning Protection + $this->defaults[ 'float' ][ '15' ] = rand( + config( 'protection.bludgeoning.min' ), + config( 'protection.bludgeoning.max' ) + ); + + //Cold Protection + $this->defaults[ 'float' ][ '16' ] = rand( + config( 'protection.cold.min' ), + config( 'protection.cold.max' ) + ); + + //Fire Protection + $this->defaults[ 'float' ][ '17' ] = rand( + config( 'protection.fire.min' ), + config( 'protection.fire.max' ) + ); + + //Acid Protection + $this->defaults[ 'float' ][ '18' ] = rand( + config( 'protection.acid.min' ), + config( 'protection.acid.max' ) + ); + + //Electrical Protection + $this->defaults[ 'float' ][ '19' ] = rand( + config( 'protection.electrical.min' ), + config( 'protection.electrical.max' ) + ); + + //Nether Protection + $this->defaults[ 'float' ][ '165' ] = rand( + config( 'protection.nether.min' ), + config( 'protection.nether.max' ) + ); + $this->spells = $this->addDefaults( 'spells' ); $spellbook = []; @@ -162,5 +222,28 @@ public function mapData( Request $request ) } $this->setAttribute( 'spellbook', $spellbook ); + + if ( !empty( $spells ) ) { + //UI Effects + $this->defaults[ 'int' ][ '18' ] = 1; + + //Spellcraft/Arcane Lore + $arcaneLore = rand( + config( $this->configKey( 'arcane-lore' ) . '.min' ), + config( $this->configKey( 'arcane-lore' ) . '.max' ) + ); + + $this->defaults[ 'int' ][ '106' ] = $arcaneLore; + $this->defaults[ 'int' ][ '109' ] = $arcaneLore; + + //Mana Usage Rate + $this->defaults[ 'float' ][ '5' ] = rand_float( 5, 33, 3 ); + } + + $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); + $this->setAttribute( 'bool', $this->addDefaults( 'bool' ) ); + $this->setAttribute( 'float', $this->addDefaults( 'float' ) ); + $this->setAttribute( 'did', $this->addDefaults( 'did' ) ); + $this->setAttribute( 'string', $this->addDefaults( 'string' ) ); } } diff --git a/app/Models/GameObject.php b/app/Models/GameObject.php index c871178..b01d90b 100644 --- a/app/Models/GameObject.php +++ b/app/Models/GameObject.php @@ -42,7 +42,8 @@ public function mapData( Request $request ) $this->{$camelCase} = $value; } - $this->setAttribute( 'tier', rand( 1, 9 ) ); + /** @todo Change tier attribute from hard-coded to a random value between 1 and 9 */ + $this->setAttribute( 'tier', 7 ); return $this; } diff --git a/app/Models/Jewelry.php b/app/Models/Jewelry.php index 4a11ac4..83c1b20 100644 --- a/app/Models/Jewelry.php +++ b/app/Models/Jewelry.php @@ -129,26 +129,36 @@ public function mapData( Request $request ) $this->setAttribute( 'weenieType', array_get( $this->stats, $this->type . '.weenieType' ) ); //Set the item type - $this->stats[ $this->type ][ 'int' ][ '1' ] = config( $this->configKey( 'item-type' ) . '.id' ); + $this->defaults[ 'int' ][ '1' ] = config( $this->configKey( 'item-type' ) . '.id' ); //Set the body location - $this->stats[ $this->type ][ 'int' ][ '9' ] = config( $this->configKey( 'body-location' ) . '.id' ); + $this->defaults[ 'int' ][ '9' ] = config( $this->configKey( 'body-location' ) . '.id' ); + + //UI Effects + $this->defaults[ 'int' ][ '18' ] = 0; + + //Pyreal Value + $this->defaults[ 'int' ][ '19' ] = rand( + config( $this->configKey( 'pyreal-value' ) . '.min' ), + config( $this->configKey( 'pyreal-value' ) . '.max' ) + ); //Bonded if ( !$request->has( 'int.33' ) ) { - $this->stats[ $this->type ][ 'int' ][ '33' ] = 0; + $this->defaults[ 'int' ][ '33' ] = 0; } + //Item Workmanship + $this->defaults[ 'int' ][ '105' ] = rand( + config( $this->configKey( 'workmanship' ) . '.min' ), + config( $this->configKey( 'workmanship' ) . '.max' ) + ); + //Attuned if ( !$request->has( 'int.114' ) ) { - $this->stats[ $this->type ][ 'int' ][ '114' ] = 0; + $this->defaults[ 'int' ][ '114' ] = 0; } - $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); - $this->setAttribute( 'bool', $this->addDefaults( 'bool' ) ); - $this->setAttribute( 'float', $this->addDefaults( 'float' ) ); - $this->setAttribute( 'did', $this->addDefaults( 'did' ) ); - $this->setAttribute( 'string', $this->addDefaults( 'string' ) ); $this->spells = $this->addDefaults( 'spells' ); $spellbook = []; @@ -160,5 +170,28 @@ public function mapData( Request $request ) } $this->setAttribute( 'spellbook', $spellbook ); + + if ( !empty( $spells ) ) { + //UI Effects + $this->defaults[ 'int' ][ '18' ] = 1; + + //Spellcraft/Arcane Lore + $arcaneLore = rand( + config( $this->configKey( 'arcane-lore' ) . '.min' ), + config( $this->configKey( 'arcane-lore' ) . '.max' ) + ); + + $this->defaults[ 'int' ][ '106' ] = $arcaneLore; + $this->defaults[ 'int' ][ '109' ] = $arcaneLore; + + //Mana Usage Rate + $this->defaults[ 'float' ][ '5' ] = rand_float( 5, 33, 3 ); + } + + $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); + $this->setAttribute( 'bool', $this->addDefaults( 'bool' ) ); + $this->setAttribute( 'float', $this->addDefaults( 'float' ) ); + $this->setAttribute( 'did', $this->addDefaults( 'did' ) ); + $this->setAttribute( 'string', $this->addDefaults( 'string' ) ); } } diff --git a/app/Traits/Wearable.php b/app/Traits/Wearable.php index 4ade9f9..b096175 100644 --- a/app/Traits/Wearable.php +++ b/app/Traits/Wearable.php @@ -113,22 +113,32 @@ protected function configKey( $configType ) case 'bracelet': $configKeys[ 'item-type' ] = 'item-type.jewelry'; $configKeys[ 'body-location' ] = 'body-location.jewelry.either-wrist'; + $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; + $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'necklace': $configKeys[ 'item-type' ] = 'item-type.misc'; //Yes, I know 'misc' doesn't make sense $configKeys[ 'body-location' ] = 'jewelry.necklace'; + $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; + $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'ring': $configKeys[ 'item-type' ] = 'item-type.misc'; //Yes, I know 'misc' doesn't make sense $configKeys[ 'body-location' ] = 'jewelry.either-finger'; + $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; + $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'coat': $configKeys[ 'item-type' ] = 'item-type.armor'; $configKeys[ 'clothing-priority' ] = 'clothing-priority.armor.chest-ul-arms'; $configKeys[ 'body-location' ] = 'body-location.armor.chest-ul-arms'; + $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.pyreal-value'; + $configKeys[ 'armor-level' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.armor-level'; + $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; + $configKeys[ 'arcane-lore' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.arcane-lore'; break; } diff --git a/config/icons.php b/config/icons.php index 7735bf0..cbd63f5 100644 --- a/config/icons.php +++ b/config/icons.php @@ -124,11 +124,37 @@ ], ], 'armor' => [ + 'amuli-coat' => [ + 'id' => 100670435, + 'name' => 'Amuli Coat', + ], + 'amuli-leggings' => [ + 'id' => 100670441, + 'name' => 'Amuli Leggings', + ], + + 'amuli' => [ + 'coat' => [ + 'id' => 100670435, + 'name' => 'Amuli Coat', + ], + 'leggings' => [ + 'id' => 100670441, + 'name' => 'Amuli Leggings', + ] + ], + 'coat' => [ 'amuli' => [ - 'id' => 100670433, - 'name' => 'Amuli', + 'id' => 100670435, + 'name' => 'Amuli Coat', ], + ], + 'leggings' => [ + 'amuli' => [ + 'id' => 100670441, + 'name' => 'Amuli Leggings', + ] ] ], ]; diff --git a/config/mana-usage.php b/config/mana-usage.php index 24d25cc..d19045a 100644 --- a/config/mana-usage.php +++ b/config/mana-usage.php @@ -8,7 +8,7 @@ return [ '30-seconds' => [ - 'id' => '0.033333333333333', + 'id' => '0.033', 'name' => '30 Seconds', ], ]; diff --git a/config/protection.php b/config/protection.php new file mode 100644 index 0000000..384752a --- /dev/null +++ b/config/protection.php @@ -0,0 +1,42 @@ + [ + 'min' => 1.0, + 'max' => 2.0, + ], + 'piercing' => [ + 'min' => 1.0, + 'max' => 2.0, + ], + 'bludgeoning' => [ + 'min' => 1.0, + 'max' => 2.0, + ], + 'cold' => [ + 'min' => 0.5, + 'max' => 1.2, + ], + 'fire' => [ + 'min' => 0.5, + 'max' => 1.2, + ], + 'acid' => [ + 'min' => 0.5, + 'max' => 1.2, + ], + 'electrical' => [ + 'min' => 0.5, + 'max' => 1.2, + ], + 'nether' => [ + 'min' => 0.6, + 'max' => 1.3, + ], +]; diff --git a/config/tiers.php b/config/tiers.php new file mode 100644 index 0000000..bf1a677 --- /dev/null +++ b/config/tiers.php @@ -0,0 +1,28 @@ + [ + 'pyreal-value' => [ + 'min' => 2500, + 'max' => 12000, + ], + 'armor-level' => [ + 'min' => 550, + 'max' => 725, + ], + 'workmanship' => [ + 'min' => 4, + 'max' => 10, + ], + 'arcane-lore' => [ + 'min' => 190, + 'max' => 310 + ], + ] +]; diff --git a/config/type.php b/config/type.php new file mode 100644 index 0000000..b15a25b --- /dev/null +++ b/config/type.php @@ -0,0 +1,24 @@ + [ + 'bracelet' => 'Bracelet', + 'necklace' => 'Necklace', + 'ring' => 'Ring', + ], + 'armor' => [ + 'amuli-coat' => [ + 'name' => 'Amuli Coat', + ], + 'mana-usage' => [ + 'min' => 5, + 'max' => 33, + ] + ] +]; diff --git a/database/migrations/2017_12_09_224942_CreateJewelryTable.php b/database/migrations/2017_12_09_224942_CreateJewelryTable.php index 7c7535c..b27540b 100644 --- a/database/migrations/2017_12_09_224942_CreateJewelryTable.php +++ b/database/migrations/2017_12_09_224942_CreateJewelryTable.php @@ -17,7 +17,7 @@ public function up() Schema::create( 'jewelry', function ( Blueprint $table ) { $table->bigIncrements( 'wcid' ); $table->string( 'type' ); - $table->string( 'tier' ); + $table->tinyinteger( 'tier' ); $table->string( 'weenieType' ); $table->text( 'int' )->nullable(); $table->text( 'bool' )->nullable(); diff --git a/database/migrations/2017_12_09_225241_CreateArmorTable.php b/database/migrations/2017_12_09_225241_CreateArmorTable.php index 0c6da84..b7817ae 100644 --- a/database/migrations/2017_12_09_225241_CreateArmorTable.php +++ b/database/migrations/2017_12_09_225241_CreateArmorTable.php @@ -17,7 +17,7 @@ public function up() Schema::create( 'armor', function ( Blueprint $table ) { $table->bigIncrements( 'wcid' ); $table->string( 'type' ); - $table->string( 'tier' ); + $table->tinyinteger( 'tier' ); $table->string( 'weenieType' ); $table->text( 'int' )->nullable(); $table->text( 'bool' )->nullable(); diff --git a/database/migrations/2017_12_09_225246_CreateWeaponTable.php b/database/migrations/2017_12_09_225246_CreateWeaponTable.php index 71a7c19..223bb5b 100644 --- a/database/migrations/2017_12_09_225246_CreateWeaponTable.php +++ b/database/migrations/2017_12_09_225246_CreateWeaponTable.php @@ -17,7 +17,7 @@ public function up() Schema::create( 'weapon', function ( Blueprint $table ) { $table->bigIncrements( 'wcid' ); $table->string( 'type' ); - $table->string( 'tier' ); + $table->tinyinteger( 'tier' ); $table->string( 'weenieType' ); $table->text( 'int' )->nullable(); $table->text( 'bool' )->nullable(); diff --git a/resources/views/armor.twig b/resources/views/armor.twig index 033dcca..47bd7e6 100644 --- a/resources/views/armor.twig +++ b/resources/views/armor.twig @@ -10,11 +10,11 @@
- {{ form_label( 'armor-type', 'Armor Type' ) }} + {{ form_label( 'type', 'Armor Type' ) }} {{ form_select( 'type', { '': '-- Select One --', 'coat': 'Coat', - }, old( 'type', '' ), { id: 'armor-type', class: 'form-control', required: true } ) }} + }, old( 'type', '' ), { id: 'type', class: 'form-control', required: true } ) }}
{{ form_label( 'icon', 'Icon' ) }} @@ -147,21 +147,6 @@ {{ form_number( 'int[108]', old( 'int[108]', '' ), { id: 'max-mana', class: 'form-control' } ) }}
-
 
-
-
- {{ form_label( 'arcane-lore', 'Player Arcane Lore Level' ) }} - {{ form_number( 'int[109]', old( 'int[109]', '' ), { id: 'arcane-lore', class: 'form-control' } ) }} - {{ form_hidden( 'int[106]', '' ) }} -
-
- - -
-

diff --git a/resources/views/components/add-spells.twig b/resources/views/components/add-spells.twig index b121dc1..9306e36 100644 --- a/resources/views/components/add-spells.twig +++ b/resources/views/components/add-spells.twig @@ -26,10 +26,6 @@ spells.append(item, ''); }); - $('#arcane-lore').on('change', function () { - $('#spellcraft').val($(this).val()); - }); - var spells = 'select[name="spells[]"]'; $(document).on('change', spells, function () { var count = $(spells).filter(function () { From f02edfd224d69f653facc54a911dded21534fa90 Mon Sep 17 00:00:00 2001 From: Lisa Riggle Date: Thu, 28 Dec 2017 23:01:33 -0600 Subject: [PATCH 2/3] Add in mutators for float values, also remove the pyreal field since that is auto-generated now. Changes to be committed: modified: app/Models/GameObject.php modified: resources/views/armor.twig modified: resources/views/jewelry.twig --- app/Models/GameObject.php | 24 ++++++++++++++++++++++-- resources/views/armor.twig | 7 ------- resources/views/jewelry.twig | 4 ---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/Models/GameObject.php b/app/Models/GameObject.php index b01d90b..eee2da9 100644 --- a/app/Models/GameObject.php +++ b/app/Models/GameObject.php @@ -17,6 +17,26 @@ abstract class GameObject extends Model ], ]; + /** + * Mutate the spellbook attribute to use a specific json option when encoding + * + * @param $value + */ + public function setSpellbookAttribute( $value ) + { + $this->attributes[ 'spellbook' ] = json_encode( $value, JSON_PRESERVE_ZERO_FRACTION ); + } + + /** + * Mutate the float attribute to use a specific json option when encoding + * + * @param $value + */ + public function setFloatAttribute( $value ) + { + $this->attributes[ 'float' ] = json_encode( $value, JSON_PRESERVE_ZERO_FRACTION ); + } + /** * @param Request $request * @@ -86,10 +106,10 @@ public function convertToJson( $pretty = true ) ]; if ( $pretty ) { - return json_encode( $json, JSON_PRETTY_PRINT ); + return json_encode( $json, JSON_PRETTY_PRINT | JSON_PRESERVE_ZERO_FRACTION ); } - return json_encode( $json ); + return json_encode( $json, JSON_PRESERVE_ZERO_FRACTION ); } /** diff --git a/resources/views/armor.twig b/resources/views/armor.twig index 47bd7e6..6647f69 100644 --- a/resources/views/armor.twig +++ b/resources/views/armor.twig @@ -48,17 +48,10 @@
 
-
- {{ form_label( 'pyreal-value', 'Pyreal Value' ) }} - {{ form_number( 'int[19]', old( 'int[19]', '' ), { id: 'pyreal-value', class: 'form-control', required: true } ) }} -
{{ form_label( 'burden-value', 'Burden Value' ) }} {{ form_number( 'int[5]', old( 'int[5]', '' ), { id: 'burden-value', class: 'form-control', required: true } ) }}
-
-
 
-
{{ form_label( 'amor-level', 'Armor Level' ) }} {{ form_number( 'int[28]', old( 'int[28]', '' ), { id: 'amor-level', class: 'form-control' } ) }} diff --git a/resources/views/jewelry.twig b/resources/views/jewelry.twig index 87009ac..673d29e 100644 --- a/resources/views/jewelry.twig +++ b/resources/views/jewelry.twig @@ -52,10 +52,6 @@
 
-
- {{ form_label( 'pyreal-value', 'Pyreal Value' ) }} - {{ form_number( 'int[19]', old( 'int[19]', '' ), { id: 'pyreal-value', class: 'form-control', required: true } ) }} -
{{ form_label( 'burden-value', 'Burden Value' ) }} {{ form_number( 'int[5]', old( 'int[5]', '' ), { id: 'burden-value', class: 'form-control', required: true } ) }} From 8fdf069521accd355b6406b99a868926a201f7aa Mon Sep 17 00:00:00 2001 From: Lisa Riggle Date: Mon, 4 May 2026 22:08:36 -0500 Subject: [PATCH 3/3] Not sure what I was working on but lets save it --- app/Helpers/common.php | 8 +- app/Models/Armor.php | 120 ++++++----- app/Models/GameObject.php | 2 + app/Models/Jewelry.php | 2 +- app/Traits/Wearable.php | 13 +- config/burden.php | 14 ++ config/colors.php | 7 + config/icons.php | 2 + config/properties.php | 398 ++++++++++++++++++++++++++++++++++++- config/type.php | 22 +- resources/views/armor.twig | 8 +- 11 files changed, 521 insertions(+), 75 deletions(-) create mode 100644 config/burden.php create mode 100644 config/colors.php diff --git a/app/Helpers/common.php b/app/Helpers/common.php index c778585..7950c4a 100644 --- a/app/Helpers/common.php +++ b/app/Helpers/common.php @@ -20,7 +20,7 @@ function current_route() } } -if ( !function_exists( 'rand_float' ) ) { +if ( !function_exists( 'float_rand' ) ) { /** * @param int $min * @param int $max @@ -28,14 +28,14 @@ function current_route() * * @return float|int */ - function rand_float( $min = 0, $max = 1, $decimalPlaces = 1 ) + function float_rand( $min = 0, $max = 1, $decimalPlaces = 1 ) { $decimal = '.'; - for ( $i = 0; $i < $places - 1; $i++ ) { + for ( $i = 1; $i < $decimalPlaces; $i++ ) { $decimal .= '0'; } $decimal .= '1'; - return rand( $min, $max ) * $decimal; + return number_format( rand( $min, $max ) * $decimal, $decimalPlaces ); } } diff --git a/app/Models/Armor.php b/app/Models/Armor.php index 92f6ae5..54d3710 100644 --- a/app/Models/Armor.php +++ b/app/Models/Armor.php @@ -9,6 +9,11 @@ class Armor extends GameObject { use Wearable; + /** + * @var string + */ + protected $armorType; + /** * The primary key for the model. * @@ -121,14 +126,23 @@ public function mapData( Request $request ) { parent::mapData( $request ); + $armorType = $request->get( 'armor_type' ); + $type = config( 'type.armor.' . $armorType ); + + $this->setAttribute( 'type', $type[ 'type' ] ); $this->setAttribute( 'weenieType', array_get( $this->stats, $this->type . '.weenieType' ) ); + //Icon + $this->defaults[ 'did' ][ '8' ] = config( 'icons.' . $armorType ); + //Set the item type $this->defaults[ 'int' ][ '1' ] = config( $this->configKey( 'item-type' ) . '.id' ); //Clothing Priority $this->defaults[ 'int' ][ '4' ] = config( $this->configKey( 'clothing-priority' ) . '.id' ); + $this->defaults[ 'int' ][ '5' ] = ''; + //Set the body location $this->defaults[ 'int' ][ '9' ] = config( $this->configKey( 'body-location' ) . '.id' ); @@ -163,53 +177,7 @@ public function mapData( Request $request ) $this->defaults[ 'int' ][ '114' ] = 0; } - //Slashing Protection - $this->defaults[ 'float' ][ '13' ] = rand( - config( 'protection.slashing.min' ), - config( 'protection.slashing.max' ) - ); - - //Piercing Protection - $this->defaults[ 'float' ][ '14' ] = rand( - config( 'protection.piercing.min' ), - config( 'protection.piercing.max' ) - ); - - //Bludgeoning Protection - $this->defaults[ 'float' ][ '15' ] = rand( - config( 'protection.bludgeoning.min' ), - config( 'protection.bludgeoning.max' ) - ); - - //Cold Protection - $this->defaults[ 'float' ][ '16' ] = rand( - config( 'protection.cold.min' ), - config( 'protection.cold.max' ) - ); - - //Fire Protection - $this->defaults[ 'float' ][ '17' ] = rand( - config( 'protection.fire.min' ), - config( 'protection.fire.max' ) - ); - - //Acid Protection - $this->defaults[ 'float' ][ '18' ] = rand( - config( 'protection.acid.min' ), - config( 'protection.acid.max' ) - ); - - //Electrical Protection - $this->defaults[ 'float' ][ '19' ] = rand( - config( 'protection.electrical.min' ), - config( 'protection.electrical.max' ) - ); - - //Nether Protection - $this->defaults[ 'float' ][ '165' ] = rand( - config( 'protection.nether.min' ), - config( 'protection.nether.max' ) - ); + $this->addProtections(); $this->spells = $this->addDefaults( 'spells' ); @@ -237,7 +205,7 @@ public function mapData( Request $request ) $this->defaults[ 'int' ][ '109' ] = $arcaneLore; //Mana Usage Rate - $this->defaults[ 'float' ][ '5' ] = rand_float( 5, 33, 3 ); + $this->defaults[ 'float' ][ '5' ] = float_rand( 5, 33, 3 ); } $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); @@ -246,4 +214,60 @@ public function mapData( Request $request ) $this->setAttribute( 'did', $this->addDefaults( 'did' ) ); $this->setAttribute( 'string', $this->addDefaults( 'string' ) ); } + + /** + * @return $this + */ + public function addProtections() + { + //Slashing Protection + $this->defaults[ 'float' ][ '13' ] = float_rand( + config( 'protection.slashing.min' ) * 10, + config( 'protection.slashing.max' ) * 10 + ); + + //Piercing Protection + $this->defaults[ 'float' ][ '14' ] = float_rand( + config( 'protection.piercing.min' ) * 10, + config( 'protection.piercing.max' ) * 10 + ); + + //Bludgeoning Protection + $this->defaults[ 'float' ][ '15' ] = float_rand( + config( 'protection.bludgeoning.min' ) * 10, + config( 'protection.bludgeoning.max' ) * 10 + ); + + //Cold Protection + $this->defaults[ 'float' ][ '16' ] = float_rand( + config( 'protection.cold.min' ) * 10, + config( 'protection.cold.max' ) * 10 + ); + + //Fire Protection + $this->defaults[ 'float' ][ '17' ] = float_rand( + config( 'protection.fire.min' ) * 10, + config( 'protection.fire.max' ) * 10 + ); + + //Acid Protection + $this->defaults[ 'float' ][ '18' ] = float_rand( + config( 'protection.acid.min' ) * 10, + config( 'protection.acid.max' ) * 10 + ); + + //Electrical Protection + $this->defaults[ 'float' ][ '19' ] = float_rand( + config( 'protection.electrical.min' ) * 10, + config( 'protection.electrical.max' ) * 10 + ); + + //Nether Protection + $this->defaults[ 'float' ][ '165' ] = float_rand( + config( 'protection.nether.min' ) * 10, + config( 'protection.nether.max' ) * 10 + ); + + return $this; + } } diff --git a/app/Models/GameObject.php b/app/Models/GameObject.php index eee2da9..ef1fd98 100644 --- a/app/Models/GameObject.php +++ b/app/Models/GameObject.php @@ -8,6 +8,8 @@ abstract class GameObject extends Model { /** + * This is different than $casts, which is what laravel uses to cast eloquent values + * * @var array */ protected $cast = [ diff --git a/app/Models/Jewelry.php b/app/Models/Jewelry.php index 83c1b20..966787b 100644 --- a/app/Models/Jewelry.php +++ b/app/Models/Jewelry.php @@ -185,7 +185,7 @@ public function mapData( Request $request ) $this->defaults[ 'int' ][ '109' ] = $arcaneLore; //Mana Usage Rate - $this->defaults[ 'float' ][ '5' ] = rand_float( 5, 33, 3 ); + $this->defaults[ 'float' ][ '5' ] = float_rand( 5, 33, 3 ); } $this->setAttribute( 'int', $this->addDefaults( 'int' ) ); diff --git a/app/Traits/Wearable.php b/app/Traits/Wearable.php index b096175..8a4c8d1 100644 --- a/app/Traits/Wearable.php +++ b/app/Traits/Wearable.php @@ -107,37 +107,32 @@ protected function addDefaults( $statType ) */ protected function configKey( $configType ) { - $configKeys = []; + $configKeys = [ + 'pyreal-value' => 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value', + 'workmanship' => 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship', + ]; switch ( $this->getAttribute( 'type' ) ) { case 'bracelet': $configKeys[ 'item-type' ] = 'item-type.jewelry'; $configKeys[ 'body-location' ] = 'body-location.jewelry.either-wrist'; - $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; - $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'necklace': $configKeys[ 'item-type' ] = 'item-type.misc'; //Yes, I know 'misc' doesn't make sense $configKeys[ 'body-location' ] = 'jewelry.necklace'; - $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; - $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'ring': $configKeys[ 'item-type' ] = 'item-type.misc'; //Yes, I know 'misc' doesn't make sense $configKeys[ 'body-location' ] = 'jewelry.either-finger'; - $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . 'pyreal-value'; - $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; break; case 'coat': $configKeys[ 'item-type' ] = 'item-type.armor'; $configKeys[ 'clothing-priority' ] = 'clothing-priority.armor.chest-ul-arms'; $configKeys[ 'body-location' ] = 'body-location.armor.chest-ul-arms'; - $configKeys[ 'pyreal-value' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.pyreal-value'; $configKeys[ 'armor-level' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.armor-level'; - $configKeys[ 'workmanship' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.workmanship'; $configKeys[ 'arcane-lore' ] = 'tiers.' . $this->getAttribute( 'tier' ) . '.arcane-lore'; break; } diff --git a/config/burden.php b/config/burden.php new file mode 100644 index 0000000..6519f5c --- /dev/null +++ b/config/burden.php @@ -0,0 +1,14 @@ + [ + 'min' => 1500, + 'max' => 3200, + ], +]; diff --git a/config/colors.php b/config/colors.php new file mode 100644 index 0000000..f3d0fbd --- /dev/null +++ b/config/colors.php @@ -0,0 +1,7 @@ + 'Amuli Leggings', ], + //organized by style 'amuli' => [ 'coat' => [ 'id' => 100670435, @@ -144,6 +145,7 @@ ] ], + //organized by armor piece 'coat' => [ 'amuli' => [ 'id' => 100670435, diff --git a/config/properties.php b/config/properties.php index c7e89f9..9c28e50 100644 --- a/config/properties.php +++ b/config/properties.php @@ -19,6 +19,7 @@ 'pallet-template' => [ 'id' => 3, 'name' => 'Pallet Template', + //'name' => 'Base Color' ], 'clothing-priority' => [ 'id' => 4, @@ -28,22 +29,74 @@ 'id' => 5, 'name' => 'Burden', ], + 'item-capacity' => [ + 'id' => 6, + 'name' => 'Item Capacity' + ], + 'container-capacity' => [ + 'id' => 7, + 'name' => 'Container Capacity', + ], + //8 = ??? 'body-location' => [ 'id' => 9, 'name' => 'Body Location', ], + //10 = ??? + 'max-stack-size' => [ + 'id' => 11, + 'name' => 'Maximum Stack Size', + ], + 'current-stack-size' => [ + 'id' => 12, + 'name' => 'Current Stack Size', + ], + //13 - same as burden + //14 - ??? + //15 - ??? 'useable' => [ 'id' => 16, 'name' => 'Usable', ], - 'ui-effects' => [ + 'rare-id' => [ + 'id' => 17, + 'name' => 'Rare ID', + ], + 'icon-outline' => [ 'id' => 18, - 'name' => 'UI Effects', + 'name' => 'Icon Outline', + //'name' => 'UI Effects', ], 'pyreal' => [ 'id' => 19, 'name' => 'Pyreal', ], + 'current-pyreal' => [ + 'id' => 20, + 'name' => 'Total Money In Inventory' + ], + 'current-experience' => [ + 'id' => 21, + 'name' => 'Current Experience' + ], + //22 - ??? + 'current-skill-credits' => [ + 'id' => 23, + 'name' => 'Current Skill Credits', + ], + 'available-skill-credits' => [ + 'id' => 24, + 'name' => 'Available Skill Credits', + ], + 'current-level' => [ + 'id' => 25, + 'name' => 'Current Level', + ], + 'account-requirement' => [ + 'id' => 26, + 'name' => 'Account Requirement', + //1 = requires Throne of Destiny + ], 'armor-type' => [ 'id' => 27, 'name' => 'Armor Type', @@ -52,14 +105,130 @@ 'id' => 28, 'name' => 'Armor Level', ], + //29 - ??? + 'allegiance-rank' => [ + 'id' => 30, + 'name' => 'Allegience Rank', + ], + 'allowed-channels' => [ + 'id' => 31, + 'name' => 'Allowed Channels', + ], + 'active-channels' => [ + 'id' => 32, + 'name' => 'Active Channels', + ], 'bonded' => [ 'id' => 33, 'name' => 'Bonded', ], + 'monarch-rank' => [ + 'id' => 34, + 'name' => 'Monarch Rank' + ], + 'current-allegiance-followers' => [ + 'id' => 35, + 'name' => 'Current Allegiance Followers', + ], + 'resist-magic' => [ + 'id' => 36, + 'name' => 'Resist Magic', + //'name' => 'Unenchantable', + ], + 'resist-appraisal' => [ + 'id' => 37, + 'name' => 'Appraisal Difficulty', + ], + 'resist-lockpick' => [ + 'id' => 38, + 'name' => 'Resist Lockpick', + ], + //39 = ??? + 'combat-mode' => [ + 'id' => 40, + 'name' => 'Combat Mode', + ], + //41 + //42 - ??? + 'current-death-count' => [ + 'id' => 43, + 'name' => 'Current Death Count', + ], + 'current-damage' => [ + 'id' => 44, + 'name' => 'Current Damage', + ], + 'damage-type' => [ + 'id' => 45, + 'name' => 'Damage Type', + ], + 'combat-style' => [ + 'id' => 46, + 'name' => 'Combat Style', + ], + 'attack-type' => [ + 'id' => 47, + 'name' => 'Attack Type', + ], + 'weapon-skill' => [ + 'id' => 48, + 'name' => 'Weapon Skill', + ], + 'weapon-speed' => [ + 'id' => 49, + 'name' => 'Weapon Speed', + ], + 'ammo-type' => [ + 'id' => 50, + 'name' => 'Ammo Type', + ], + //51 - ??? + //52 - ??? 'placement-position' => [ 'id' => 53, 'name' => 'Placement Position', ], + //54 + //55 + //56 + //57 + //58 + //59 + //60 + //61 + //62 + //63 + //64 + //65 + //66 + 'tolerance' => [ + 'id' => 67, + 'name' => 'Tolerance', + ], + //68 + //69 + //70 + //71 + 'friend-type' => [ + 'id' => 72, + 'name' => 'Friend Type', + ], + 'foe-type' => [ + 'id' => 73, + 'name' => 'Foe Type', + ], + //74 + //75 + //76 + //77 + //78 + //79 + //80 + //81 + //82 + //83 + //84 + //85 'player-min-level' => [ 'id' => 86, 'name' => 'Player Minimum Level', @@ -68,10 +237,42 @@ 'id' => 87, 'name' => 'Player Maximum Level', ], + //88 + //89 + //90 + 'max-uses' => [ + 'id' => 91, + 'name' => 'Max Uses', + ], + 'current-uses' => [ + 'id' => 92, + 'name' => 'Current Uses' + ], 'physics' => [ 'id' => 93, 'name' => 'Physics', ], + //94 + 'radar-color' => [ + 'id' => 95, + 'name' => 'Radarblip Color' + ], + //96 + 'login-timestamp' => [ + 'id' => 97, + 'name' => 'Login Timestamp', + ], + 'creation-timestamp' => [ + 'id' => 98, + 'name' => 'Creation Timestamp', + //'name' => 'Birth Timestamp', + ], + //99 + //100 + //101 + //102 + //103 + //104 'workmanship' => [ 'id' => 105, 'name' => 'Item Workmanship', @@ -92,14 +293,84 @@ 'id' => 109, 'name' => 'Player Minimum Arcane Lore', ], + 'min-allegiance-rank' => [ + 'id' => 110, + 'name' => 'Allegiance Rank Requirement', + ], + //111 + //112 + 'gender' => [ + 'id' => 113, + 'name' => 'Gender', + ], 'attuned' => [ 'id' => 114, 'name' => 'Attuned', ], + 'min-skill-level' => [ + 'id' => 115, + 'name' => 'Skill Level Requirement', + ], + //116 + //117 + //118 + //119 + 'attack-height' => [ + 'id' => 120, + 'name' => 'Attack Height', + ], + //121 + //122 + //123 + //124 + 'age' => [ + 'id' => 125, + 'name' => 'Age', + ], + //126 + //127 + //128 + //129 + //130 'material-type' => [ 'id' => 131, 'name' => 'Material Type', ], + //132 + 'showable-on-radar' => [ + 'id' => 133, + 'name' => 'Showable on Radar', + ], + 'pk-status' => [ + 'id' => 134, + 'name' => 'PK Status', + ], + //135 + //136 + //137 + //138 + //139 + //140 + //141 + //142 + //143 + //144 + //145 + //146 + //147 + //148 + //149 + //150 + //151 + //152 + //153 + //154 + 'house-type' => [ + 'id' => 155, + 'name' => 'House Type', + ], + //156 + //157 'wield-requirement' => [ 'id' => 158, 'name' => 'Wield Requirement', @@ -112,6 +383,14 @@ 'id' => 160, 'name' => 'Wield Difficulty', ], + //161 + //162 + //163 + //164 + //165 + //166 + //167 + //168 'tsys-data' => [ 'id' => 169, 'name' => 'TSYS Mutation Data', @@ -133,4 +412,119 @@ 'name' => 'Weenie Type', ], ], + 'bool' => [ + 'ignore-collision' => [ + 'id' => 11, + 'name' => 'Ignore Collision', + ], + 'etherial' => [ + 'id' => 13, + 'name' => 'Etherial', + ], + 'gravity' => [ + 'id' => 14, + 'name' => 'Gravity', + ], + 'attackable' => [ + 'id' => 19, + 'name' => 'Attackable', + ], + 'inscribeable' => [ + 'id' => 22, + 'name' => 'Inscribeable', + ], + ], + 'float' => [ + 'mana-usage' => [ + 'id' => 5, + 'name' => 'Mana Usage', + ], + 'shade-1' => [ + 'id' => 12, + 'name' => 'Shade 1', + ], + 'slashing-protection' => [ + 'id' => 13, + 'name' => 'Slashing Protection', + ], + 'piercing-protection' => [ + 'id' => 14, + 'name' => 'Piercing Protection', + ], + 'bludgeoning-protection' => [ + 'id' => 15, + 'name' => 'Bludgeoning Protection', + ], + 'cold-protection' => [ + 'id' => 16, + 'name' => 'Cold Protection', + ], + 'fire-protection' => [ + 'id' => 17, + 'name' => 'Fire Protection', + ], + 'acid-protection' => [ + 'id' => 18, + 'name' => 'Acid Protection', + ], + 'electrical-protection' => [ + 'id' => 19, + 'name' => 'Electrical Protection', + ], + 'shade-2' => [ + 'id' => 84, + 'name' => 'Shade 2', + //'name' => 'Trim 1', + ], + 'shade-3' => [ + 'id' => 85, + 'name' => 'Shade 3', + //'name' => 'Trim 2', + ], + 'shade-4' => [ + 'id' => 86, + 'name' => 'Shade 4', + //'name' => 'Trim 3', + ], + 'nether-protection' => [ + 'id' => 165, + 'name' => 'Nether Protection', + ], + ], + 'did' => [ + 'ground-pallet' => [ + 'id' => 1, + 'name' => 'Ground Pallet', + ], + 'sound-pallet' => [ + 'id' => 3, + 'name' => 'Sound Pallet', + ], + 'cokir-pallet' => [ + 'id' => 6, + 'name' => 'Sound Pallet', + ], + 'clothing-base' => [ + 'id' => 7, + 'name' => 'Clothing Base', + ], + 'icon' => [ + 'id' => 8, + 'name' => 'Icon', + ], + 'physics-effect' => [ + 'id' => 22, + 'name' => 'Physics Effect', + ], + ], + 'string' => [ + 'item-name' => [ + 'id' => 1, + 'name' => 'Item Name', + ], + 'additional-description' => [ + 'id' => 16, + 'name' => 'Additional Description' + ], + ], ]; diff --git a/config/type.php b/config/type.php index b15a25b..ebf1e91 100644 --- a/config/type.php +++ b/config/type.php @@ -8,17 +8,25 @@ return [ 'jewelry' => [ - 'bracelet' => 'Bracelet', - 'necklace' => 'Necklace', - 'ring' => 'Ring', + 'bracelet' => [ + 'name' => 'Bracelet', + 'type' => 'bracelet', + + ], + 'necklace' => [ + 'name' => 'Necklace', + 'type' => 'necklace', + ], + 'ring' => [ + 'name' => 'Ring', + 'type' => 'ring', + ], ], 'armor' => [ 'amuli-coat' => [ 'name' => 'Amuli Coat', + 'type' => 'coat', + 'style' => 'amuli', ], - 'mana-usage' => [ - 'min' => 5, - 'max' => 33, - ] ] ]; diff --git a/resources/views/armor.twig b/resources/views/armor.twig index 6647f69..a1e67af 100644 --- a/resources/views/armor.twig +++ b/resources/views/armor.twig @@ -10,11 +10,11 @@
- {{ form_label( 'type', 'Armor Type' ) }} - {{ form_select( 'type', { + {{ form_label( 'armor-type', 'Armor Type' ) }} + {{ form_select( 'armor_type', { '': '-- Select One --', - 'coat': 'Coat', - }, old( 'type', '' ), { id: 'type', class: 'form-control', required: true } ) }} + 'amuli-coat': 'Amuli Coat', + }, old( 'armor_type', '' ), { id: 'armor-type', class: 'form-control', required: true } ) }}
{{ form_label( 'icon', 'Icon' ) }}