theFarWilds.com
http://thefarwilds.com/forum/

Code Suggestions
http://thefarwilds.com/forum/viewtopic.php?f=14&t=1807
Page 1 of 1

Author:  queeshai [ Fri Apr 02, 2010 11:46 pm ]
Post subject:  Code Suggestions

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 );}

Author:  jed [ Sat Apr 03, 2010 12:08 pm ]
Post subject:  Re: Code Suggestions

That setAllTerrian function times out for you?

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

Author:  queeshai [ Sat Apr 03, 2010 4:48 pm ]
Post subject:  Re: Code Suggestions

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.

Author:  jed [ Mon Apr 05, 2010 4:07 pm ]
Post subject:  Re: Code Suggestions

weird setAllTerrain doesn't timeout for me?
I also added getMapWidth,getMapHeight, and constants for all the terrain types.

Author:  angelatheist [ Tue Apr 06, 2010 3:24 am ]
Post subject:  Re: Code Suggestions

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)

Author:  emancipate [ Tue Apr 06, 2010 5:36 am ]
Post subject:  Re: Code Suggestions

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();

Author:  jed [ Tue Apr 06, 2010 12:58 pm ]
Post subject:  Re: Code Suggestions

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();

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/