~ubuntu-branches/ubuntu/trusty/enigma/trusty-proposed

« back to all changes in this revision

Viewing changes to src/stones/PassageStone.cc

  • Committer: Package Import Robot
  • Author(s): Erich Schubert
  • Date: 2013-04-06 14:54:02 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130406145402-jgjrtk7hac8gtvza
Tags: 1.20-dfsg.1-1
* New upstream release (Closes: #704595)
  (Repacked: dropped zipios++ source and main menu music)
* Update watch file, sf.net again.
* Fix documentation links (Closes: #653508)
* Conflict with enigma-level-previews to encourage deinstallation
  (Pregenerated level previews were only used with version 1.01)
* Use dh7 for building instead of CDBS
* Update to policy 3.9.4.0 (no changes)
* Register documentation with doc-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * modify it under the terms of the GNU General Public License
6
6
 * as published by the Free Software Foundation; either version 2
7
7
 * of the License, or (at your option) any later version.
8
 
 *  
 
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
10
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
24
 
25
25
namespace enigma {
26
26
 
27
 
    PassageStone::PassageStone(int color, int flavor) : Stone() {
 
27
    PassageStone::PassageStone(int color, int theflavor) : Stone() {
28
28
        state = color;
29
 
        objFlags |= (flavor << 24);
 
29
        objFlags |= (theflavor << 24);
30
30
    }
31
 
    
 
31
 
32
32
    std::string PassageStone::getClass() const {
33
33
        return "st_passage";
34
34
    }
35
 
    
 
35
 
36
36
    void PassageStone::setAttr(const string& key, const Value &val) {
37
37
        if (key == "color") {
38
38
            Stone::setAttr("state", val);
53
53
        } else
54
54
            Stone::setAttr(key, val);
55
55
    }
56
 
    
 
56
 
57
57
    Value PassageStone::getAttr(const std::string &key) const {
58
58
        if (key == "color") {
59
59
            return state;
62
62
        }
63
63
        return Stone::getAttr(key);
64
64
    }
65
 
    
 
65
 
66
66
    Value PassageStone::message(const Message &m) {
67
67
        if (m.message == "signal" || m.message == "_trigger") {
68
68
            toggleState();
70
70
        }
71
71
        return Stone::message(m);
72
72
    }
73
 
    
 
73
 
74
74
    void PassageStone::init_model()  {
75
75
        set_model(ecl::strf("st_passage_%s_%s", (state == BLACK) ? "black" : "white", flavor().c_str()));
76
76
    }
78
78
    bool PassageStone::is_floating() const {
79
79
        return true;
80
80
    }
81
 
    
 
81
 
82
82
    bool PassageStone::is_transparent (Direction d) const {
83
83
        return true;
84
84
    }
85
 
    
 
85
 
86
86
    StoneResponse PassageStone::collision_response(const StoneContact &sc) {
87
 
        Value accolor = sc.actor->getAttr("color"); 
88
 
        
 
87
        Value accolor = sc.actor->getAttr("color");
 
88
 
89
89
        if (server::GameCompatibility != GAMET_ENIGMA && sc.actor->getClass() != "ac_marble")
90
90
            return STONE_REBOUND;
91
 
            
 
91
 
92
92
        if (state == BLACK) {
93
93
            return (accolor && accolor == BLACK) ?  STONE_PASS : STONE_REBOUND;
94
94
        }
96
96
            return (accolor && accolor == WHITE) ?  STONE_PASS : STONE_REBOUND;
97
97
        }
98
98
    }
99
 
    
 
99
 
100
100
    std::string PassageStone::flavor() const {
101
101
        switch ((objFlags & OBJBIT_FLAVOR) >> 24) {
102
102
            case 0 : return "square";
104
104
            case 2 : return "cross";
105
105
            case 3 : return "frame";
106
106
        }
107
 
        ASSERT(false, XLevelRuntime, "PassageStone unknown flavor");
 
107
        throw XLevelRuntime("PassageStone unknown flavor");
108
108
    }
109
109
 
110
110
    int PassageStone::traitsIdx() const {
121
121
        {"st_passage_white_cross",  st_passage_white_cross,  stf_transparent, material_stone, 1.0, MOVABLE_PERSISTENT},
122
122
        {"st_passage_white_frame",  st_passage_white_frame,  stf_transparent, material_stone, 1.0, MOVABLE_PERSISTENT},
123
123
    };
124
 
    
 
124
 
125
125
    BOOT_REGISTER_START
126
126
        BootRegister(new PassageStone(BLACK, 0), "st_passage");
127
127
        BootRegister(new PassageStone(BLACK, 0), "st_passage_black");