forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Sat Nov 18, 2017 4:34 am

All times are UTC




Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu May 27, 2010 10:32 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Set a different "SC-win-count":
Here you need to edit variant.php:
Code:
class Sengoku5Variant extends WDVariant {
   
   public function initialize() {
      parent::initialize();
      $this->supplyCenterTarget = 25;
   }   

}


Top
 Profile  
 
PostPosted: Fri Jun 25, 2010 8:21 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Make colored staring territories with "neutral" SC's.
It's not necessary for a variant to work, but it makes a nice map that shows a historical occupation, but keeps the "Home"-SCs for players at a reasonable size.
Here's an example (Chungking is neutral, but it's colored as Chinese) :
Attachment:
example.png
example.png [ 1.87 KiB | Viewed 1803 times ]

The box is a PNG-file (one for the smallmap and one for the largemap) you have to put in your resources directory.
Here are the icons:
Attachment:
sc_large.png
sc_large.png [ 2.76 KiB | Viewed 1804 times ]
Attachment:
sc_small.png
sc_small.png [ 2.76 KiB | Viewed 1802 times ]

All the action is done in the drawmap.php:
Code:
<?php
class SouthAmerica8Variant_drawMap extends drawMap {

   /**
    * An array containing the neutral support-center icon image resource, and its width and height.
    * $image['image'],['width'],['height']
    * @var array
    */
   protected $sc=array();
   
   /**
    * An array containing the information if one of the territories
    * still has a neutral support-center (So we might not need to draw a flag)
    */
   protected $nsc=array();

   // Load all the images and after that the neutral-box image
   protected function loadImages()
   {
      parent::loadImages();

      if( $this->smallmap )
         $this->sc = $this->loadImage('variants/SouthAmerica8/resources/sc_small.png');
      else
         $this->sc = $this->loadImage('variants/SouthAmerica8/resources/sc_large.png');
   }

   // Set the transparent backgrounds for all the images and after that the background for the neutral-SC image
   protected function setTransparancies()
   {
      parent::setTransparancies();
      $this->setTransparancy($this->sc);
   }   
   

   /* There are territories on the map that belong to a country but have a supply-center that is considered "neutral"
   ** They are set to owner "Neutral" in the installation-file and because of that would get drawn in the neutral-color
   ** We need to check if they are still "neutal" and paint the territory in the color of the country they "should" belong to.
   ** after that we draw the "neutral-sc-image" on the map.
   **
   ** terrID is the ID of the territory, and if countryID is still 0 it's still neutral and we need to set the countryID to the owner
   ** it should belong before we call the original paint routine. $sx and $sy are the coordinates the neutral-box is drawn
   ** after we colored the territory
   */
   public function ColorTerritory($terrID, $countryID)   
   {
      if     ($terrID ==  4 && $countryID == 0 && $this->smallmap)  { $sx=205; $sy=482; $countryID=1; } // Patagonia smallmap
      elseif ($terrID ==  4 && $countryID == 0 && !$this->smallmap) { $sx=349; $sy=825; $countryID=1; } // Patagonia largemap
      elseif ($terrID ==  5 && $countryID == 0 && $this->smallmap)  { $sx=190; $sy=342; $countryID=1; } // San Miguel de Tucuman
      elseif ($terrID ==  5 && $countryID == 0 && !$this->smallmap) { $sx=312; $sy=585; $countryID=1; } // " largemap
      
      parent::ColorTerritory($terrID, $countryID);
      $this->nsc[$terrID]=0;

      // Did we set a sx? If yes we need to draw the box and set nsc of this terrID to 1
      // if nsc is 1 we know that territory is considered neutral, but is colored
      if (isset($sx))
      {
         $this->putImage($this->sc, $sx, $sy);
         $this->nsc[$terrID]=1;
      }
      
   }
   

   /* No need to draw the country flags for "neural-SC-territories if they get occupied by
   ** the country they should belong to
   ** That means nsc of that territory is 1 and there is a unit from that player on this territory.
   ** Normally it would draw a flag, because the territory is "neutral" This is to prevent this behaviour
   */
   public function countryFlag($terrID, $countryID)
   {
      if (($this->nsc[4]  == 1) && ($terrID ==  4) && ( $countryID == 1)) return;
      if (($this->nsc[5]  == 1) && ($terrID ==  5) && ( $countryID == 1)) return;
      parent::countryFlag($terrID, $countryID);
   }   
   
}
?>


Top
 Profile  
 
PostPosted: Sun Jul 18, 2010 5:46 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
I did quite some improvements to some of the snippets and added the "neutral units" too.
But it's a pain to update this thread every time I change something. So made just a download-package on my homepage. (http://olidip.net/download.php)

Oliver


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group