]> git.localhorst.tv Git - alttp.git/commitdiff
display seed code
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 16 Mar 2022 13:45:34 +0000 (14:45 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 16 Mar 2022 13:45:34 +0000 (14:45 +0100)
app/Models/Round.php
database/migrations/2022_03_16_083537_add_seed_code.php [new file with mode: 0644]
resources/js/components/common/ZeldaIcon.js [new file with mode: 0644]
resources/js/components/rounds/Item.js
resources/js/components/rounds/SeedCode.js [new file with mode: 0644]
resources/js/i18n/de.js
resources/sass/common.scss
resources/sass/rounds.scss

index 3b84c554e3e6320b2290c8b751930bef0d7ea69e..e93501079aa3ca183cac26ad7c455bff48422a67 100644 (file)
@@ -17,6 +17,10 @@ class Round extends Model
                return $this->belongsTo(Tournament::class);
        }
 
+       protected $casts = [
+               'code' => 'array',
+       ];
+
        protected $fillable = [
                'tournament_id',
        ];
diff --git a/database/migrations/2022_03_16_083537_add_seed_code.php b/database/migrations/2022_03_16_083537_add_seed_code.php
new file mode 100644 (file)
index 0000000..db63d5a
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('rounds', function(Blueprint $table) {
+                       $table->text('code');
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('rounds', function(Blueprint $table) {
+                       $table->dropColumn('code');
+               });
+       }
+};
diff --git a/resources/js/components/common/ZeldaIcon.js b/resources/js/components/common/ZeldaIcon.js
new file mode 100644 (file)
index 0000000..84f2220
--- /dev/null
@@ -0,0 +1,80 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import { withTranslation } from 'react-i18next';
+
+import i18n from '../../i18n';
+
+const getIconURL = name => {
+       switch (name) {
+               case 'big-key':
+               case 'blue-boomerang':
+               case 'blue-mail':
+               case 'blue-pendant':
+               case 'blue-potion':
+               case 'bombos':
+               case 'bomb':
+               case 'book':
+               case 'boots':
+               case 'bottle-bee':
+               case 'bottle':
+               case 'bow':
+               case 'bugnet':
+               case 'byrna':
+               case 'cape':
+               case 'compass':
+               case 'crystal':
+               case 'duck':
+               case 'ether':
+               case 'fairy':
+               case 'fighter-shield':
+               case 'fire-rod':
+               case 'fire-shield':
+               case 'flippers':
+               case 'flute':
+               case 'glove':
+               case 'green-mail':
+               case 'green-pendant':
+               case 'green-potion':
+               case 'hammer':
+               case 'heart-container':
+               case 'heart-piece':
+               case 'hookshot':
+               case 'ice-rod':
+               case 'lamp':
+               case 'map':
+               case 'mirror':
+               case 'mirror-shield':
+               case 'mitts':
+               case 'moonpearl':
+               case 'mushroom':
+               case 'powder':
+               case 'quake':
+               case 'red-bomb':
+               case 'red-boomerang':
+               case 'red-mail':
+               case 'red-pendant':
+               case 'red-potion':
+               case 'shovel':
+               case 'silvers':
+               case 'small-key':
+               case 'somaria':
+                       return `/item/${name}.png`;
+               default:
+                       return '';
+       }
+};
+
+const ZeldaIcon = ({ name }) =>
+<span className="zelda-icon">
+       <img
+               alt={i18n.t(`icon.zelda.${name}`)}
+               src={getIconURL(name)}
+               title={i18n.t(`icon.zelda.${name}`)}
+       />
+</span>;
+
+ZeldaIcon.propTypes = {
+       name: PropTypes.string,
+};
+
+export default withTranslation()(ZeldaIcon);
index 1832edb4c13bb5e08f90f1731f1866884ffcd452..c17a5aa6f058cd438d657a79b3b0ac147e1f2725 100644 (file)
@@ -1,12 +1,12 @@
 import PropTypes from 'prop-types';
 import React from 'react';
-import { Button } from 'react-bootstrap';
 import { withTranslation } from 'react-i18next';
 
 import SeedButton from './SeedButton';
+import SeedCode from './SeedCode';
 import List from '../results/List';
 import ReportButton from '../results/ReportButton';
-import { maySetSeed, isParticipant } from '../../helpers/permissions';
+import { isParticipant } from '../../helpers/permissions';
 import { findParticipant } from '../../helpers/Tournament';
 import { withUser } from '../../helpers/UserContext';
 import i18n from '../../i18n';
@@ -24,6 +24,9 @@ const Item = ({
                        {i18n.t('rounds.date', { date: new Date(round.created_at) })}
                </p>
                <p className="seed">
+                       {round.code ?
+                               <SeedCode code={round.code} />
+                       : null}
                        <SeedButton
                                round={round}
                                tournament={tournament}
@@ -45,6 +48,7 @@ const Item = ({
 Item.propTypes = {
        index: PropTypes.number,
        round: PropTypes.shape({
+               code: PropTypes.arrayOf(PropTypes.string),
                created_at: PropTypes.string,
                seed: PropTypes.string,
        }),
diff --git a/resources/js/components/rounds/SeedCode.js b/resources/js/components/rounds/SeedCode.js
new file mode 100644 (file)
index 0000000..1539c18
--- /dev/null
@@ -0,0 +1,17 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+
+import ZeldaIcon from '../common/ZeldaIcon';
+
+const SeedCode = ({ code }) =>
+<span className="seed-code">
+       {code.map((symbol, index) =>
+               <ZeldaIcon key={`${symbol}.${index}`} name={symbol} />
+       )}
+</span>;
+
+SeedCode.propTypes = {
+       code: PropTypes.arrayOf(PropTypes.string),
+};
+
+export default SeedCode;
index 97089e6013fe89a6dc450cb73f6db1aad669a57d..27a2a4022aed37aee49360f5f7a26cf471485ae3 100644 (file)
@@ -28,6 +28,60 @@ export default {
                        PendingIcon: 'Ausstehend',
                        SecondPlaceIcon: 'Zweiter Platz',
                        ThirdPlaceIcon: 'Dritter Platz',
+                       zelda: {
+                               'big-key': 'Big Key',
+                               'blue-boomerang': 'Boomerang',
+                               'blue-mail': 'Blue Mail',
+                               'blue-pendant': 'Pendant of Power',
+                               'blue-potion': 'Blue Potion',
+                               bombos: 'Bombos',
+                               bomb: 'Bomb',
+                               book: 'Book',
+                               boots: 'Boots',
+                               'bottle-bee': 'Bee in a Bottle',
+                               bottle: 'Bottle',
+                               bow: 'Bow',
+                               bugnet: 'Bugnet',
+                               byrna: 'Cane of Byrna',
+                               cape: 'Cape',
+                               compass: 'Compass',
+                               crystal: 'Crystal',
+                               duck: 'Duck',
+                               ether: 'Ether',
+                               fairy: 'Fairy in a Bottle',
+                               'fighter-shield': 'Fighter Shield',
+                               'fire-rod': 'Fire Rod',
+                               'fire-shield': 'Fire Shield',
+                               flippers: 'Flippers',
+                               flute: 'Flute',
+                               glove: 'Power Glove',
+                               'green-mail': 'Green Mail',
+                               'green-pendant': 'Pendant of Courage',
+                               'green-potion': 'Green Potion',
+                               hammer: 'Hammer',
+                               'heart-container': 'Heart Container',
+                               'heart-piece': 'Heart Piece',
+                               hookshot: 'Hookshot',
+                               'ice-rod': 'Ice Rod',
+                               lamp: 'Lamp',
+                               map: 'Map',
+                               mirror: 'Mirror',
+                               'mirror-shield': 'Mirror Shield',
+                               mitts: 'Titan \'s Mitts',
+                               moonpearl: 'Moonpearl',
+                               mushroom: 'Mushroom',
+                               powder: 'Powder',
+                               quake: 'Quake',
+                               'red-bomb': 'Red Bomb',
+                               'red-boomerang': 'Red Boomerang',
+                               'red-mail': 'Red Mail',
+                               'red-pendant': 'Pendant of Wisdom',
+                               'red-potion': 'Red Potion',
+                               shovel: 'Shovel',
+                               silvers: 'Silvers',
+                               'small-key': 'Small Key',
+                               somaria: 'Cane of Somaria',
+                       },
                },
                participants: {
                        empty: 'Noch keine Teilnehmer eingetragen',
index f585be09416b6912a4d7b9efa104d8fe072cbf1d..57d0d5fc30da60db6c503a76e3f87eb29deb4669 100644 (file)
@@ -20,3 +20,16 @@ h1 {
 .text-bronze {
        color: $bronze;
 }
+
+.zelda-icon {
+       display: inline-flex;
+       align-items: center;
+       width: 2em;
+       height: 2em;
+
+       img {
+               margin: auto;
+               max-width: 100%;
+               max-height: 100%;
+       }
+}
index ee38c8237e287b9c139140a5a2a5900fc3ef3774..f258d46fd0f82b7585222be23531b62d61f112d4 100644 (file)
                        .date {
                                font-size: 125%;
                        }
+
+                       .seed-code {
+                               margin: 1rem 0;
+                       }
                }
        }
 }
+
+.seed-code {
+       display: flex;
+       flex-direction: row;
+       flex-wrap: nowrap;
+       align-items: center;
+       align-content: center;
+       justify-content: flex-start;
+       gap: 0.5ex;
+}