From: Erik V. <eri...@hc...> - 2005-04-17 14:32:23
|
During the last week I have been working on some further low-level classes. The following ones are new: - Certificate / CertificateI (public company share papers). - Portfolio, discussed before. Certificates are held in a ListArray per company, accessed via a HashMap. This works easiest. There still also is an overall ArrayList of certificates, but I think that one is redundant. - CashHolder: an interface implemented by all money holders, to allow cash transfer. This is done via a static method Bank.transferCash (CashHolder from, CashHolder to, int amount). To avoid the need to have a Bank instance everywhere I have added the shortcut, that either 'from' or 'to' may be null, in which case it is the Bank. - Log: to log the proceeds (currently to System.out) and make the increments after each action available for display (see below). I have also created a new test servlet (GameTestServlet). On my website (http://home.hccnet.nl/erik.vos/18xx.html) I have added 6 screenshots of HTML output from this servlet, which shows, that most of the simple actions during a game already can be done. Also the Log output is shown. Below more on this servlet. Currently implemented features (partly in the servlet, but all using underlying code in the base classes): - Share buying and selling (but no presidency change yet). All done via a Portfolio method buyCertificate (CertificateI certificate, Portfolio from, int price) [which calls transferCash for the monetary part of the transaction). - Correct dividend payout and withholding. - Private buying and payout, also by and to companies. - Correct stock marker movements, including when sold out. Not covered yet are: - Trains, tokens and tiles (but the servlet allows a company to spend any amount on whatever). - Private special properties, i.e. B&O does not come with the president's share (so better subtract $200 from the private price!) and does not close when B&O operates (buys a train). - Player order, operating order, priority. - Money amount limit checking (e.g. when buying privates). Also negative cash still allowed. I have not done much to the XML files yet. Only addition is the definition of Certificates per company type and/or per company (see the 1830 Company.Manager.xml file). Many details (like the bank size and player initial cash) are now hardcoded the 1830 way, but that will be changed soon. If Certificates are defined per CompanyType, these will be cloned into each company which has not itself defined a certificate array. I plan to change this so, that a <CompanyType> can contain a whole dummy company with all possible features, all of which will be cloned into the <Company> if not overridden. How does this all fit into our project's architecture? I see it like this: +------------------------------------+ | Upper layer = View (UI) | | display, produce events | +------------------------------------+ | Middle layer = Model (game logic) | | catch events, call data objects | +------------------------------------+ | Lower layer = Model (data objects) | | file interfaces, object states | +------------------------------------+ The game classes I have developed so far cover part of the lowest layer. The test servlet replaces the top 2 layers, and already contains code fragments that I think will end up in the middle layer classes. But I have no idea yet on how this middle layer will actually look like. Unfortunately, UI development seems to be lagging behind. All I can contribute right now is in defining the lower layer components and their interfaces (APIs) with the middle layer. In this respect, what I have done so far looks pretty good, taking into account the things that can already be done (see the screen shots). Hopefully the upper/middle layer development will get a boost now.... It turns out Brett does not want the servlet code in the project repository (or maybe just not below the game package). If it does not get another place, so be it; I'm happy to send this code to anyone who is interested in how I'm using the base classes developed so far. Anyhow, I'll continue this way, which is the only one that works for me right now. Erik. |
From: Brett <wak...@ea...> - 2005-04-17 20:14:18
|
On Sun, 2005-04-17 at 16:32 +0200, Erik Vos wrote: > How does this all fit into our project's architecture? > I see it like this: > > +------------------------------------+ > | Upper layer = View (UI) | > | display, produce events | > +------------------------------------+ > | Middle layer = Model (game logic) | > | catch events, call data objects | > +------------------------------------+ > | Lower layer = Model (data objects) | > | file interfaces, object states | > +------------------------------------+ > IMO, this looks about right. > The test servlet replaces the top 2 layers, and already > contains code fragments that I think will end up > in the middle layer classes. But I have no idea yet > on how this middle layer will actually look like. > Unfortunately, UI development seems to be lagging behind. > Yes. Unfortunately I haven't had much time in the last month to work on the UI. I think that'll be changing. > It turns out Brett does not want the servlet code in the project repository > (or maybe just not below the game package). If it does not get another > place, so be it; I'm happy to send this code to anyone who is interested > in how I'm using the base classes developed so far. > Anyhow, I'll continue this way, which is the only one that works > for me right now. I sent you an e-mail privately about this, but it might be useful to duplicate some of that here, publicly. After looking at the extent to which you've developed the servlet, I think it deserves a place in the test directory at the project root. I only wish developing in swing were as easy. ;-) ---Brett. LBNC (luser brain not connected) |