Login    Forum    Search    FAQ

Board index » Scenarios & Scripting




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Code Suggestions
 Post Posted: Fri Apr 02, 2010 11:46 pm 
Offline

Joined: Fri Nov 13, 2009 8:26 am
Posts: 139
NOTE: when I say to "remove" something, I mean to remove it from the public API ... so backwards compatibility with core code can still be retained.

I'd like to see these as global functions:

Code:
int getMapSizeX();
int getMapSizeY();

////////////////////////////////////////////////////////////
// NOTE1: this doesn't work now due to timing out of script
// perhaps this should live in configGame and replace normal map generation
// NOTE2: maxX and maxY should be derived by global get functions
void setAllTerrain( int topo, int veg, int maxX, int maxY )
{
  Location el;
 
  for( int x = 0; x < maxX; x++ )
  {
    for( int y = 0; y < maxY; y++ )
    {
      el = createLocation( x, y );
      setTerrain( el, topo, veg );
    }
  }
}


I'd like to see these as methods of Player:

Code:
// coded as a global function for now, since I can't see the members of Player
void removeDeck( Player p )
{
  int ds = p.deckSize();
 
  for( int i = 0; i < ds; i++ )
  {
    p.removeDeckCard(0);
  }
}

// remove createEntity( string CardName, int x_coord, int y_coord, Player controller )
// remove createEntity( string CardName, Location loc, Player controller )
Entity createEntity( string CardName, Location loc );


I'd like to see these as methods of Entity:

Code:
// remove Location.isAloft()
bool isAloft();

// remove global enchantEntity()
// also note that this now returns the new enchantment Entity
Entity enchant( string enchantName, Player enchantController );

// make isType() private (or remove)
bool isCreature() {return isType( 1 );}
bool isBuilding() {return isType( 2 );}
bool isEnchantment() {return isType( 3 );}
bool isItem() {return isType( 4 );} // not sure what this is ...
bool isCorpse() {...}
bool isRuin() {...}
bool isFluxWell() {...}

// make setDim() private (or remove)
void dim() {setDim( true );}
void undim() {setDim( false );}


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Sat Apr 03, 2010 12:08 pm 
Offline

Joined: Tue Jan 08, 2008 2:07 am
Posts: 1045
That setAllTerrian function times out for you?

createEntity can't be a member of Player since not all entities have controllers.


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Sat Apr 03, 2010 4:48 pm 
Offline

Joined: Fri Nov 13, 2009 8:26 am
Posts: 139
jed wrote:
That setAllTerrian function times out for you?


yes. the script in its entirety is here: http://thefarwilds.com/story/view.php?sid=115

jed wrote:
createEntity can't be a member of Player since not all entities have controllers.


there are currently three (publicly accessible) constructors:

Code:
Entity createEntity( string CardName, int x_coord, int y_coord, Player controller );
Entity createEntity( string CardName, Location loc, Player controller );
Entity createEntity( string CardName, Location loc );


I was suggesting that the first constructor be removed entirely -- give people two ways to do something and they'll use both, making the code more complicated. the second constructor should become a method of Player. the third one can be left as a global function for now; but, what I'd really like to see would be a global Map object which would own the third constructor along with the other map related functions I suggested.

in case you can't tell, I think globals are generally a bad thing and the less that exist, the better.


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Mon Apr 05, 2010 4:07 pm 
Offline

Joined: Tue Jan 08, 2008 2:07 am
Posts: 1045
weird setAllTerrain doesn't timeout for me?
I also added getMapWidth,getMapHeight, and constants for all the terrain types.


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Tue Apr 06, 2010 3:24 am 
Offline

Joined: Mon Mar 02, 2009 11:00 am
Posts: 150
functions i would like to see

Entity:
void addToken(type);
void removeToken(type);
int numTokens(type);
someway to figure out what card a ruin/corpse used to be.

Location
bool isAdjacent(Location loc);
int getx();
int gety();

Player
some way to adjust the AI's behavior (e.g. offensive/defensive)

_________________
ȁ̎̉̈̂̎͋̈́̍n͂͑̿ͥͣ́̓ġͤ͑ͯe͌̓̊ͩ͗̅l̽̓ͬͬͥ̊͗aͣ̔̃ͧ̓̾̾t͊̑̆hͤ͆̓̉̌ͣ̚e̋ͩ͒̈́ĭ̌̒̎ͧ̓̋ͪs̋ͤͧ̅̇̋̎ͫ̂̾ͨ̽̄ͫͯt͒͐̌ͭ̂̃ͪ̽ͣ͗̒ͣ


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Tue Apr 06, 2010 5:36 am 
Offline
User avatar

Joined: Fri May 01, 2009 9:17 pm
Posts: 119
Location: behind you eating your cookies...
I want a more streamlined way of making corpses or ruins, instead of the current

Code:
Entity chucknorris=createEntity("cookies",8,8,aiPlayer);
        chuchnorris.destroy();


Top 
 Profile  
 
 Post subject: Re: Code Suggestions
 Post Posted: Tue Apr 06, 2010 12:58 pm 
Offline

Joined: Tue Jan 08, 2008 2:07 am
Posts: 1045
ok I added:
Entity:
int addTokens(string tokenName,int delta);
// returns the number of that token after the add.
// delta can be negative

int numTokens(string tokenName);

string otherName();
// returns the name of the corpse, ruin,
// or construction site building that this was or will be

Location:
int distance(Location);
int getX();
int getY();


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 7 posts ] 

Board index » Scenarios & Scripting


Who is online

Users browsing this forum: No registered users and 3 guests

 
 

 
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: