SWU-Karabast / SWUOnline

Star Wars Unlimited Sim
GNU General Public License v3.0
41 stars 32 forks source link

Making DJ not returning your own resources #259

Closed Raising closed 1 month ago

Raising commented 1 month ago

I got a fix for DJ when you steal a resource from the oponent and defeat such resource, is not perfect as is not tagging the resource to the DJ unit, but at least i wont give a resource owned by you.

cardGetters.php@230 add

  function &GetControlledButNotOwnedResourceCards($player)
 {
   global $ownResources = &GetResourceCards($player)

   // Filter out the resources that are owned by the player
   $filteredResources = array_filter($ownResources, function($resource) use ($player) {
       $owner = MZPlayerID($player, $resource); 
       return $owner <> $player;
   });

   return $filteredResources;
}

AllyAbilities.php@306 replace

        $notOwnedresources = &GetControlledButNotOwnedResourceCards($player);
        if (count($notOwnedresources) > 0) {
          $resources = &GetResourceCards($player);
          $resIndex = array_search(end($notOwnedresources), $resources );
          $resourceCard = RemoveResource($player, $resIndex);
          AddResources($resourceCard, $otherPlayer, "PLAY", "DOWN");
        }