Exemplo n.º 1
0
 public function getAvailableUnits($id)
 {
     $file = file_get_contents("units.txt");
     $units = json_decode($file, true);
     $position = Position::find($id);
     $x = $position->x;
     $y = $position->y;
     $position = Position::where('y', $y)->where('x', $x)->get()->lists('id');
     $city = City::whereIn('position_id', $position)->get();
     if (count($city) == 0) {
         return $city;
     } else {
         switch ($city[0]->tier) {
             case 1:
                 $txt = 'tier1';
                 break;
             case 2:
                 $txt = 'tier2';
                 break;
         }
         $units = Unit::whereIn('Id', $units[$txt])->with('resource')->get();
         return \App\CityEffectApplier::modifyUnitPricesByCity($units, $city[0]);
     }
 }
Exemplo n.º 2
0
 public function getCityArmyIsIn($army)
 {
     $position = Position::where('y', $army->position->y)->where('x', $army->position->x)->get()->lists('id');
     $city = City::whereIn('position_id', $position)->get();
     return $city[0];
 }