[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [QUIZ] Space Merchant (#71

Dimitri Aivaliotis

3/23/2006 5:43:00 AM

I know this is 11th-hour and all, but I thought I'd mention it
anyways. When I read this quiz, I immediately thought of using a
Dependency Injection framework to solve it. I also wanted to add
elements of the Firefly `Verse to the gameplay, so I'd describe it in
a YAML file. Unfortunately, I haven't had the time to do more than
just a mock-up:

registry = Needle::Registry.new do |reg|

reg.register( :galaxy ) { Galaxy.new( 'firefly.yaml' ) }
reg.intercept( :galaxy ).with! { logging_interceptor }
reg.register( :sector, :model => :multiton ) do |c,p,name,location|
Sector.new( name, location )
end
reg.intercept( :sector ).with! { logging_interceptor }
reg.register( :planet, :model => :multiton ) do |c,p,name,sector|
Planet.new( name, sector )
end
reg.intercept( :planet ).with! { logging_interceptor }
reg.register( :station, :model => :multiton ) do |c,p,name,sector|
Station.new( name, sector )
end
reg.intercept( :station ).with! { logging_interceptor }
reg.register( :player, :model => :multiton ) do |c,p,name|
Player.new( name )
end
reg.intercept( :player ).with! { logging_interceptor }
end

galaxy = registry.galaxy

firefly.yaml (partial):

---
galaxy: firefly
player:
credits : 1000
reputation : 100
sectors:
- name : 1
location : central
planets:
- name : Ariel
description : "Planet. Home to a major medical center, Saint Lucy's."
- name : 2
location : central
planets:
- name : Persephone
description : Planet. Heavily stratified societal structure.
Resupply port for Serenity.

I had envisioned this as a webapp, where players could register and
all play within the same universe. The Authenticator and Presenter
aren't shown above. Each player would then be instatiated like so:

<username> = registry.player("<username>")

They could save the game state to a YAML file, which would then be
transportable across SpaceMerchant implementations.

So, what do you all think? Anybody with actual DI/IoC experience care
to chime in? (As you can probably tell, this would be my first time
using DI.) Are there any other Browncoats out there? Could this
maybe be a Part 2 to this quiz?

- Dimitri


2 Answers

Shane Emmons

3/23/2006 12:30:00 PM

0

I would be willing to help. I have been thinking for months on a way to
implement a game in the verse. Let me know what's going on, until then
I will just drift out here in the black.

James Gray

3/23/2006 1:56:00 PM

0

On Mar 22, 2006, at 11:43 PM, Dimitri Aivaliotis wrote:

> I had envisioned this as a webapp, where players could register and
> all play within the same universe.

I *almost* made the quiz like this, but changed my mind to keep
things a little easier. It's a good idea.

James Edward Gray II