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

« back to all changes in this revision

Viewing changes to src/items/SurpriseItem.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
30
30
/* -------------------- Surprise item -------------------- */
31
31
    SurpriseItem::SurpriseItem() : Item() {
32
32
    }
33
 
    
 
33
 
34
34
    std::string SurpriseItem::getClass() const {
35
35
        return "it_surprise";
36
36
    }
45
45
                "it_hammer"
46
46
            };
47
47
            if (Value v = Item::getAttr(key))
48
 
                return v; 
 
48
                return v;
49
49
            else {
50
50
                TokenList tl;
51
51
                for (int i = 0; i < 5; i++)
55
55
        } else
56
56
            return Item::getAttr(key);
57
57
    }
58
 
    
 
58
 
59
59
    void SurpriseItem::on_drop(Actor *a) {
60
 
        int id = getId();
 
60
        int theid = getId();
61
61
            performAction(true);    // may kill the stone!
62
 
        
63
 
        if (Object::getObject(id) != NULL) {  // not killed?
 
62
 
 
63
        if (Object::getObject(theid) != NULL) {  // not killed?
64
64
            TokenList tl = getAttr("selection");
65
65
            int idx = enigma::IntegerRand(1, tl.size()) - 1;
66
66
            TokenList::iterator itr = tl.begin();
67
 
            for (int i = 0; i < idx; i++, ++itr); 
 
67
            for (int i = 0; i < idx; i++, ++itr);
68
68
            std::string name = (*itr).to_string();
69
69
            if (name.find('=') == 0) {
70
70
                if (lua::CallFunc(lua::LevelState(), "enigma.settile", name.substr(1), this)) {
75
75
            }
76
76
        }
77
77
    }
78
 
    
 
78
 
79
79
    DEF_ITEMTRAITS(SurpriseItem, "it_surprise", it_surprise);
80
80
 
81
81
    BOOT_REGISTER_START