SKS Änderungen

master
Seph 2024-05-02 21:29:31 +02:00
parent 7f98344e3d
commit 7e556ff7a5
7 changed files with 91 additions and 26 deletions

View File

@ -4,7 +4,7 @@ Theme URI: https://nebelkrieger.de
Author: Yorndar
Author URI: https://nebelkrieger.de
Description: The next gen NK-Theme
Version: 0.1.1
Version: 0.2.1
Tested up to: 6.2
Requires PHP: 8.0
License: GNU General Public License v2 or later

View File

@ -1,6 +1,7 @@
<?php
use WoWPress\Models\Raid;
use WoWPress\Models\SKS;
use WoWPress\Models\User;
add_filter('generate_rewrite_rules', function ($wp_rewrite) {
@ -11,7 +12,7 @@ add_filter('generate_rewrite_rules', function ($wp_rewrite) {
['raid/(\d+)/?$' => 'index.php?wowpress_page=raid&raid_id=$matches[1]'],
['request/?$' => 'index.php?wowpress_page=form_request'],
['sks/?$' => 'index.php?wowpress_page=sks'],
['sks/([A-Za-z-]+)?$' => 'index.php?wowpress_page=sks&list_name=$matches[1]'],
['sks/([A-Za-z-0-9 ]+)?$' => 'index.php?wowpress_page=sks&list_name=$matches[1]'],
$wp_rewrite->rules
);
});

View File

@ -1,9 +1,47 @@
{
"Warlock" : "Hexenmeister",
"Destruction": "Zerstörung",
"Demonology": "Dämonologie",
"Affliction": "Gebrechen",
"Evoker" : "Rufer",
"Augmentation": "Verstärkung",
"Devastation" : "Verheerung",
"Preservation": "Bewahrung",
"Paladin": "Paladin",
"Retribution": "Vergeltung",
"Holy": "Heilig",
"Protection": "Schutz",
"Monk" : "Mönch",
"Windwalker" : "Windläufer"
"Windwalker" : "Windläufer",
"Brewmaster": "Braumeister",
"Mistweaver": "Nebelwirker",
"Warrior": "Krieger",
"Arms": "Waffen",
"Fury": "Furor",
"_Protection" : "Schutz",
"Hunter": "Jäger",
"Beast Mastery": "Tierherrschaft",
"Marksmanship": "Treffsicherheit",
"Survival": "Überleben",
"Rogue": "Schurke",
"Assassination": "Meucheln",
"Outlaw": "Gesetzlosigkeit",
"Subtlety": "Täuschung",
"Priest": "Priester",
"Discipline": "Disziplin",
"_Holy": "Heilig",
"Shadow": "Schatten",
"Shaman": "Schamane",
"Elemental": "Elementar",
"Enhancement": "Verstärkung",
"Restoration": "Wiederherstellung"
}

View File

@ -9,9 +9,9 @@ use WoWPress\Models\SKS;
set_sidebar_status('top', false);
$liste = $GLOBALS['wowpress']['liste'];
if(!empty($liste)){
$liste = SKS::where('list_name',$liste)->first();
if(empty($liste->list_name)){
if (!empty($liste)) {
$liste = SKS::where('list_name', $liste)->first();
if (empty($liste->list_name)) {
$liste = SKS::first();
}
}
@ -80,7 +80,7 @@ if (empty($liste->list_name)) {
<?php wp_nonce_field('fixSKS', 'fixSKS_nonce'); ?>
<input type="hidden" name="action" value="fixSKS">
<input type="hidden" name="sks_id" value="<?= $sk->ID ?>">
</div>
</form>
@ -138,7 +138,7 @@ if (empty($liste->list_name)) {
<?php
}
if (current_user_can('wowpress_edit_characters')) : ?>
if (current_user_can('wowpress_edit_raids')) : ?>
<div x-data>
<template x-teleport="#sidebar_right">
<div class="bg-glass shadow p-auto order-1">
@ -156,6 +156,22 @@ if (current_user_can('wowpress_edit_characters')) : ?>
</form>
</div>
</template>
<?php if (!empty($liste->list_name)) : ?>
<template x-teleport="#sidebar_right">
<div class="bg-glass shadow p-auto order-1">
<h4 class="text-xl font-bold text-center mb-2">Liste neu Würfeln</h4>
<form action="/request" method="POST">
<div class="flex flex-col gap-2">
<?php wp_nonce_field('rollSKS', 'rollSKS_nonce'); ?>
<input type="hidden" name="action" value="rollSKS">
<input type="hidden" name="list_name" value="<?= $liste->list_name ?>">
<button type="submit" class="btn btn-outline btn-orange"><?= Icon::get('o-arrow-path') ?> Würfeln</a>
</div>
</form>
</div>
</template>
<?php endif; ?>
</div>
<?php

View File

@ -204,25 +204,35 @@ switch ($_POST['action']) {
if (isset($_POST['sks_id'])) {
$sks = SKS::find($_POST['sks_id']);
if ($sks->ID) {
$sks->loot();
}
}
}
break;
case 'fixSKS':
isAllowed('wowpress_edit_raids');
if (isset($_POST['fixSKS_nonce']) && wp_verify_nonce($_POST['fixSKS_nonce'], 'fixSKS')) {
if (isset($_POST['sks_id']) && isset($_POST['rank'])) {
$sks = SKS::find($_POST['sks_id']);
if ($sks->ID) {
$sks->rank = intval($_POST['rank']);
$sks->save();
}
case 'rollSKS':
isAllowed('wowpress_edit_raids');
if (isset($_POST['rollSKS_nonce']) && wp_verify_nonce($_POST['rollSKS_nonce'], 'rollSKS')) {
if (isset($_POST['list_name'])) {
$sks = SKS::where('list_name', $_POST['list_name'])->first();
if (!empty($sks->ID)) {
$sks->roll();
}
}
break;
}
break;
case 'fixSKS':
isAllowed('wowpress_edit_raids');
if (isset($_POST['fixSKS_nonce']) && wp_verify_nonce($_POST['fixSKS_nonce'], 'fixSKS')) {
if (isset($_POST['sks_id']) && isset($_POST['rank'])) {
$sks = SKS::find($_POST['sks_id']);
if ($sks->ID) {
$sks->rank = intval($_POST['rank']);
$sks->save();
}
}
}
break;
}
header('Location: ' . $_SERVER['HTTP_REFERER']);

View File

@ -25,20 +25,20 @@ function hasSearch($specs)
<?php endif; ?>
<?php foreach ($instance['classes'] as $class => $specs) : ?>
<?php if($this->hasSpec($specs)): ?>
<div class="col-span-1"><img src="<?=Character::classIconLink($class)?>" alt="" class="h-8"></div>
<div class="col-span-1"><img src="<?=Character::classIconLink($class)?>" title="<?=translate_string($class)?>" alt="" class="h-8"></div>
<div class="col-span-4 grid grid-cols-subgrid">
<?php foreach ($specs as $spec => $search) : ?>
<div><img src="<?=Character::specIconLink($class,$spec)?>" alt=""
<?php
switch($search){
case 3: ?>class="h-8 border border-red-500" title="Hoch"<?php
case 3: ?>class="h-8 border border-red-500" title="<?=translate_string($spec)?>: Hoch"<?php
break;
case 2: ?>class="h-8 opacity-70 border border-yellow-500" title="Mittel"<?php
case 2: ?>class="h-8 opacity-70 border border-yellow-500" title="<?=translate_string($spec)?>: Mittel"<?php
break;
case 1: ?>class="h-8 opacity-50 border border-green-500" title="Niedrig"<?php
case 1: ?>class="h-8 opacity-50 border border-green-500" title="<?=translate_string($spec)?>: Niedrig"<?php
break;
case 0:
default: ?>class="h-8 opacity-10" title="Suche geschlossen"<?php
default: ?>class="h-8 opacity-10" title="<?=translate_string($spec)?>: Suche geschlossen"<?php
break;
}
?>

View File

@ -33,7 +33,7 @@ class BossKills extends Widget
}
return (($done/100)*count($bosses))*1000;
return ($done/count($bosses))*100;
}
public function form($instance)