Skip to content

Commit

Permalink
Merge branch '1.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Sep 7, 2021
2 parents fcf979b + 5e0db55 commit 185514a
Show file tree
Hide file tree
Showing 21 changed files with 489 additions and 230 deletions.
50 changes: 50 additions & 0 deletions app/Console/Commands/WeeklyCelestialSpawnEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Console\Commands;

use App\Game\Messages\Events\GlobalMessageEvent;
use Cache;
use Illuminate\Console\Command;
use Facades\App\Flare\Values\UserOnlineValue;
use App\Flare\Jobs\WeeklyCelestialSpawnEvent as SpawnCancelingJob;

class WeeklyCelestialSpawnEvent extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'weekly:celestial-spawn';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Makes celestials spawn 80% more once a week for a couple hours.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*/
public function handle() {
Cache::put('celestial-spawn-rate', .8);

SpawnCancelingJob::dispatch()->delay(now()->addDay());

event(new GlobalMessageEvent('The gates have swung open and the Celestial\'s are free.
get your weapons ready! (Celestials have a 80% chance to spawn regardless of plane based on any
movement type except traverse - for the next 24 hours! Only one will spawn per hour unless it is killed.)'
));
}
}
3 changes: 3 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ protected function schedule(Schedule $schedule) {

// Give people a chance to win daily lottery for gold dust
$schedule->command('daily:gold-dust')->dailyAt('12:00')->timezone(config('app.timezone'));

// Give people a chance to win daily lottery for gold dust
$schedule->command('weekly:celestial-spawn')->weeklyOn(3, '13:00')->timezone(config('app.timezone'));

// Clear the celestials every hour.
$schedule->command('clear:celestials')->hourly()->timezone(config('app.timezone'));
Expand Down
27 changes: 27 additions & 0 deletions app/Flare/Jobs/WeeklyCelestialSpawnEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Flare\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;

class WeeklyCelestialSpawnEvent implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* Create a new job instance.
*/
public function __construct() {}

public function handle() {

if (Cache::has('celestial-spawn-rate')) {
Cache::delete('celestial-spawn-rate');
}
}
}
26 changes: 22 additions & 4 deletions app/Flare/Traits/Controllers/ItemsShowInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Flare\Traits\Controllers;

use Auth;
use Illuminate\Contracts\View\View;
use App\Flare\Models\Adventure;
use App\Flare\Models\GameSkill;
use App\Flare\Models\Item;
Expand All @@ -14,7 +15,26 @@

trait ItemsShowInformation {

/**
* Renders show view.
*
* @param string $viewName
* @param Item $item
* @return View
* @throws \Exception
*/
public function renderItemShow(string $viewName, Item $item) {
return view($viewName, $this->itemShowDetails($item));
}

/**
* Get base details.
*
* @param Item $item
* @return array
* @throws \Exception
*/
public function itemShowDetails(Item $item): array {
$effects = 'N/A';
$skills = [];
$skill = null;
Expand Down Expand Up @@ -51,8 +71,6 @@ public function renderItemShow(string $viewName, Item $item) {
$skills = $query->pluck('name')->toArray();
}



if ($item->usable) {
if (Auth::guest() || auth()->user()->hasRole('Admin')) {
$skill = GameSkill::where('type', SkillTypeValue::ALCHEMY)->first();
Expand All @@ -63,7 +81,7 @@ public function renderItemShow(string $viewName, Item $item) {
}
}

return view($viewName, [
return [
'item' => $item,
'monster' => Monster::where('quest_item_id', $item->id)->first(),
'quest' => Quest::where('item_id', $item->id)->first(),
Expand All @@ -72,6 +90,6 @@ public function renderItemShow(string $viewName, Item $item) {
'effects' => $effects,
'skills' => $skills,
'skill' => $skill,
]);
];
}
}
12 changes: 9 additions & 3 deletions app/Flare/View/Livewire/Market/CurrentListings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ class CurrentListings extends Component
public $character = null;

protected $paginationTheme = 'bootstrap';

public function getDataQueryProperty() {
$marketBoard = MarketBoard::where('character_id', $this->character->id)->join('characters', function($join) {
$join->on('characters.id', '=', 'market_board.character_id');
})->join('items', function($join) {
$join->on('items.id', '=', 'market_board.item_id');
$join = $join->on('items.id', '=', 'market_board.item_id');

if (!empty($this->search)) {
$join->where('items.name', 'like', '%'.$this->search.'%');
}

return $join;
})->select('market_board.*');

return $marketBoard->orderBy($this->sortField, $this->sortBy);
}

Expand Down
8 changes: 8 additions & 0 deletions app/Game/Core/Services/InventorySetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ protected function hasSpells(InventorySet $inventorySet) {
return $slot->item->type === 'spell-damage';
}));

if ($damageSpells->count() >= 2) {
return false;
}

if ($healingSpells->count() >= 2) {
return false;
}

if ($healingSpells->count() >= 2 && $damageSpells->count() > 0) {
return false;
}
Expand Down
10 changes: 9 additions & 1 deletion app/Game/Maps/Services/MovementService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use App\Game\Maps\Values\MapTileValue;
use App\Game\Maps\Values\MapPositionValue;
use App\Game\Messages\Events\GlobalMessageEvent;
use Illuminate\Support\Facades\Cache;

class MovementService {

Expand Down Expand Up @@ -433,7 +434,14 @@ public function celestialEntities(): array {
* @return bool
*/
public function canConjure() {
return rand(1, self::CHANCE_FOR_CELESTIAL_TO_SPAWN) > (self::CHANCE_FOR_CELESTIAL_TO_SPAWN - 1);

$needed = self::CHANCE_FOR_CELESTIAL_TO_SPAWN - 1;

if (Cache::has('celestial-spawn-rate')) {
$needed = $needed - ($needed * Cache::get('celestial-spawn-rate'));
}

return rand(1, self::CHANCE_FOR_CELESTIAL_TO_SPAWN) > $needed;
}

/**
Expand Down
32 changes: 26 additions & 6 deletions app/Game/Market/Controllers/Api/MarketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,43 @@ public function history(HistoryRequest $request) {
if ($request->has('type')) {
return response()->json([
'labels' => MarketHistory::where('market_history.created_at', '>=', $when)->join('items', function($join) use($request) {
return $join->on('market_history.item_id', '=', 'items.id')
->where('items.type', $request->type);
$join = $join->on('market_history.item_id', '=', 'items.id')
->where('items.type', $request->type);

if ($request->has('item_id')) {
$join->where('items.id', $request->item_id);
}

return $join;
})->select('market_history.*')->get()->map(function($mh) {
return $mh->created_at->format('y-m-d');
}),
'data' => MarketHistory::where('market_history.created_at', '>=', $when)->join('items', function($join) use($request) {
return $join->on('market_history.item_id', '=', 'items.id')
->where('items.type', $request->type);
$join = $join->on('market_history.item_id', '=', 'items.id')
->where('items.type', $request->type);

if ($request->has('item_id')) {
$join->where('items.id', $request->item_id);
}

return $join;
})->select('market_history.*')->get()->pluck('sold_for'),
]);
} else {
$labels = MarketHistory::where('created_at', '>=', $when);
$data = MarketHistory::where('created_at', '>=', $when);

if ($request->has('item_id')) {
$labels = $labels->where('item_id', $request->item_id);
$data = $data->where('item_id', $request->item_id);
}
}

return response()->json([
'labels' => MarketHistory::where('created_at', '>=', $when)->get()->map(function($mh) {
'labels' => $labels->get()->map(function($mh) {
return $mh->item->affix_name;
}),
'data' => MarketHistory::where('created_at', '>=', $when)->get()->pluck('sold_for'),
'data' => $data->get()->pluck('sold_for'),
]);
}

Expand Down
13 changes: 9 additions & 4 deletions app/Game/Market/Controllers/MarketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Game\Market\Controllers;

use App\Flare\Traits\Controllers\ItemsShowInformation;
use Illuminate\Http\Request;
use League\Fractal\Manager;
use App\Http\Controllers\Controller;
Expand All @@ -15,7 +16,7 @@

class MarketController extends Controller {

use UpdateMarketBoard;
use UpdateMarketBoard, ItemsShowInformation;

private $manager;

Expand Down Expand Up @@ -66,9 +67,13 @@ public function editCurrentListings(MarketBoard $marketBoard) {
$this->sendUpdate($this->transformer, $this->manager);
}

return view('game.core.market.edit-current-listing', [
'marketBoard' => $marketBoard
]);
$item = $this->itemShowDetails($marketBoard->refresh()->item);

unset($item['item']);

return view('game.core.market.edit-current-listing', array_merge([
'marketBoard' => $marketBoard,
], $item));
}

public function updateCurrentListing(Request $request, MarketBoard $marketBoard) {
Expand Down
11 changes: 11 additions & 0 deletions resources/info/celestials/section-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@ any player, moving (directional buttons), teleportation or setting sail.
When a Celestial Entity is conjured or spawns, there is a chance for the creature, if it lands on a kingdom, to do damage to the kingdom.
This is a one-in-a-billion chance to do damage.

> ## ATTN!
>
> Every week at 1pm America/Edmonton time the gates will swing open! This gives Celestials across any plane a 80%
> chance to spawn based on any players' movement action, with the exception of traverse.
>
> During this time only one will spawn till its killed, if it is not killed, it will be removed in the hourly reset.
>
> This event will last for 1 day and start every Wednesday at 1pm America/Edmonton time.
>
> Players will want access to all planes as well as the ability to walk on both types of water, Surface and Labyrinth's water as well as Dungeons.
Below are is a table of all the Celestial Entities:
9 changes: 9 additions & 0 deletions resources/info/disenchanting/section-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ Clicking Destroy all will destroy all non equipped and quest items in your inven
When managing your inventory, if you destroy or disenchant all items in your inventory that are capable of being destroyed or
disenchanted the gold dust amount will update on the game tab. (This assumes, you play with a tab open for the game, and a tab open for your inventory)


## Daily Lotto

Every day at 12:00pm America/Edmonton Time, there will be a chance for one player to win 10K in gold dust while others get between 1 and 1000 gold dust.

Players do not have to do anything for this, if you are logged in you will see this in your top bar as well as in the chat!

The person who wins the lottery, triggers a global message.
15 changes: 13 additions & 2 deletions resources/js/components/marketboard/board.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import ReactDatatable from '@ashvin27/react-datatable';
import {Tab, Tabs} from 'react-bootstrap';
import Card from '../game/components/templates/card';
import MarketHistory from './market-history';
import PurchaseModal from './purchase-modal';
Expand Down Expand Up @@ -59,6 +60,7 @@ export default class Board extends Component {
hasItemId: false,
allowBuying: true,
type: null,
loading: true,
}

this.update = Echo.join('update-market');
Expand All @@ -77,6 +79,7 @@ export default class Board extends Component {
this.setState({
records: result.data.items,
gold: result.data.gold,
loading: false,
});
}).catch((error) => {
if (error.hasOwnProperty('response')) {
Expand Down Expand Up @@ -162,7 +165,6 @@ export default class Board extends Component {
});
}


axios.get('/api/market-board/items', params).then((result) => {
this.setState({
records: result.data.items,
Expand Down Expand Up @@ -233,7 +235,16 @@ export default class Board extends Component {
>
{this.state.message !== null ? this.renderMessage() : null}

{!this.state.hasItemId && this.state.allowBuying ? <MarketHistory type={this.state.type}/> : null}
<MarketHistory type={this.state.type} itemId={this.props.hasOwnProperty('itemId') ? this.props.itemId : null}/>

{
this.state.loading ?
<div className="progress mb-2 mt-2" style={{position: 'relative', height: '5px'}}>
<div className="progress-bar progress-bar-striped indeterminate">
</div>
</div>
: null
}

<ReactDatatable
config={this.config}
Expand Down
Loading

0 comments on commit 185514a

Please sign in to comment.