game-village-politics-backend/app/Models/GameEvent.php

61 lines
1.8 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** A timed effect. The engine runs due events in (fire_at, id) order. */
class GameEvent extends Model
{
public const BUILD_ORDER_FINISHED = 'build_order.finished';
public const BARBARIAN_GROWS = 'barbarian.grows';
// A barbarian garrison gets part of its full strength back.
public const BARBARIAN_REGROUPS = 'barbarian.regroups';
// Raiders from the nearest barbarian camp gather against this village; plans the next raid too.
public const RAID_PLANNED = 'raid.planned';
public const RECRUIT_FINISHED = 'recruit.finished';
public const LEVY_ENDS = 'levy.ends';
// subject_id is a row of wounded in the village's hospital; they stand again.
public const WOUNDED_HEALED = 'wounded.healed';
public const FOOD_RUNS_OUT = 'food.runs_out';
public const DESERTION = 'starvation.desertion';
// subject_id is the movement; village_id the village it arrives at.
public const MOVEMENT_ARRIVES = 'movement.arrives';
// The target starts to see an incoming group; only pushes the change.
public const MOVEMENT_SPOTTED = 'movement.spotted';
// The owner calls support back: village_id is the host, subject_id the support's home village.
public const SUPPORT_RECALLED = 'support.recalled';
// A trade route sends its next shipment: village_id is where it starts, subject_id the route.
public const TRADE_ROUTE = 'trade.route';
protected $guarded = [];
protected $dateFormat = 'Y-m-d H:i:s.v';
protected function casts(): array
{
return [
'fire_at' => 'immutable_datetime',
'processed_at' => 'immutable_datetime',
];
}
public function village(): BelongsTo
{
return $this->belongsTo(Village::class);
}
}