Changeset 180

Show
Ignore:
Timestamp:
11/17/04 21:29:13 (4 years ago)
Author:
ged
Message:

-- Added initial implementation of FaerieMUD::Verb.

Location:
branches/simplest-thing
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • branches/simplest-thing/lib/fm/event.rb

    r172 r180  
    5353    ############################################################# 
    5454 
     55    # Who, What, Where, and to Whom? 
     56 
    5557    def initialize( args={} ) 
    56         checkForHashArgs( args, :instigator, :origin ) 
     58        checkForHashArgs( args, :instigator, :origin, :verb ) 
    5759        super 
    5860    end 
     
    6870    # The origin Locus of the event -- a FaerieMUD::Locus object. 
    6971    attr_accessor :origin 
     72 
     73    # The verb that generated the event. 
     74    attr_accessor :verb 
    7075 
    7176    # The intended target of the event -- may be either +nil+ or a 
  • branches/simplest-thing/tests/event.tests.rb

    r172 r180  
    3636    class TestEntity < FaerieMUD::Entity; end 
    3737    class TestLocus < FaerieMUD::Locus; end 
     38    class TestVerb < FaerieMUD::Verb; end 
    3839 
    3940    module Complex; end 
     
    4849        @entity = TestEntity::new 
    4950        @locus = TestLocus::new 
     51        @verb = TestVerb::new 
     52        super 
    5053    end 
    5154 
    5255    # Discard testing objects 
    5356    def teardown 
     57        super 
    5458        @entity = @locus = nil 
    5559    end 
     
    7175        assert_raises( ArgumentError ) { 
    7276            derivClass = Class::new( FaerieMUD::Event ) 
    73             derivObject = derivClass::new( :origin => @locus ) 
     77            derivObject = derivClass::new( 
     78                :origin => @locus, 
     79                :verb => @verb 
     80                ) 
    7481        } 
    7582 
     
    7784        assert_raises( ArgumentError ) { 
    7885            derivClass = Class::new( FaerieMUD::Event ) 
    79             derivObject = derivClass::new( :instigator => @entity ) 
     86            derivObject = derivClass::new( 
     87                :instigator => @entity, 
     88                :verb => @verb 
     89                ) 
     90        } 
     91 
     92        # Instantiation requires a :verb 
     93        assert_raises( ArgumentError ) { 
     94            derivClass = Class::new( FaerieMUD::Event ) 
     95            derivObject = derivClass::new( 
     96                :instigator => @entity, 
     97                :origin => @locus 
     98                ) 
    8099        } 
    81100 
     
    83102        assert_nothing_raised { 
    84103            derivClass = Class::new( FaerieMUD::Event ) 
    85             derivObject = derivClass::new( :instigator => @entity, :origin => @locus ) 
     104            derivObject = derivClass::new(  
     105                :instigator => @entity, 
     106                :origin => @locus, 
     107                :verb => @verb 
     108                ) 
    86109        } 
    87110 
     
    96119        # Simple 1-deep inheritance 
    97120        assert_nothing_raised { 
    98             ev = MyEvent::new( :instigator => @entity, :origin => @locus ) 
     121            ev = MyEvent::new( 
     122                :instigator => @entity, 
     123                :origin => @locus, 
     124                :verb => @verb 
     125                ) 
    99126            rval = ev.handlerNames 
    100127        } 
     
    106133        # Complex 2-deep with mixin 
    107134        assert_nothing_raised { 
    108             ev = YourEvent::new( :instigator => @entity, :origin => @locus ) 
     135            ev = YourEvent::new( 
     136                :instigator => @entity, 
     137                :origin => @locus, 
     138                :verb => @verb 
     139                ) 
    109140            rval = ev.handlerNames 
    110141        } 
  • branches/simplest-thing/tests/locus.tests.rb

    r172 r180  
    3636            args[:instigator] ||= FaerieMUD::Locus::new 
    3737            args[:origin] ||= args[:instigator] 
     38            args[:verb] ||= FaerieMUD::Verb::new 
    3839            super( args ) 
    3940        end