bstring Player::consider(Creature* creature) const { int diff=0; bstring str = ""; if(creature->mFlagIsSet(M_UNKILLABLE)) return(""); // staff always needle if(creature->isStaff() && !isStaff()) diff = -4; else if(isStaff() && !creature->isStaff()) diff = 4; else { diff = level - creature->getLevel(); diff = MAX(-4, MIN(4, diff)); } // upHeShe is used most often str = creature->upHeShe(); switch(diff) { case 0: str += " is a perfect match for you!\n"; break; case 1: str += " is not quite as good as you.\n"; break; case -1: str += " is a little better than you.\n"; break; case 2: str += " shouldn't be too tough to kill.\n"; break; case -2: str += " might be tough to kill.\n"; break; case 3: str += " should be easy to kill.\n"; break; case -3: str += " should be really hard to kill.\n"; break; case 4: str = "You could kill "; str += creature->himHer(); str += " with a needle.\n"; break; case -4: str += " could kill you with a needle.\n"; break; } return(str); }
bool y::ldap::account::save() { // remove user if needed if(flaggedForRemoval() && !dn().get().empty()) { if(isStudent()) { y::Smartschool().unregisterStudent(*this); } else { y::Smartschool().deleteUser(*this); } y::samba::delUser(*this); if(isStudent()) return true; } // accounts without DN are not valid if(dn().get().empty()) { flagForRemoval(); return false; } // else apply changes dataset values(server); // on first save, some new entries have to be added if(!_hasKrbName) { // add kerberos objectClass data & d = values.New(ADD); d.add("type", "objectClass"); d.add("values", "kerberosSecurityObject"); // add kerberos name (for short mail) string krbName(_uid().get()); krbName += "@"; krbName += utils::Config().getDomain(); data & d1 = values.New(ADD); d1.add("type", "krbName"); d1.add("values", krbName); _hasKrbName = true; } if(!_hasSchoolPersonClass) { data & d = values.New(ADD); d.add("type", "objectClass"); d.add("values", "schoolPerson"); _hasSchoolPersonClass = true; } _cn.saveToLdap(values); _sn.saveToLdap(values); _fullName.saveToLdap(values); _homeDir.saveToLdap(values); _wisaID.saveToLdap(values); _wisaName.saveToLdap(values); _mail.saveToLdap(values); _mailAlias.saveToLdap(values); _birthDay.saveToLdap(values); _role.saveToLdap(values); _groupID.saveToLdap(values); _schoolClass.saveToLdap(values); _classChange.saveToLdap(values); _birthPlace.saveToLdap(values); _gender.saveToLdap(values); _adminGroup.saveToLdap(values); _registerID.saveToLdap(values); _nationality.saveToLdap(values); _stemID.saveToLdap(values); _schoolID.saveToLdap(values); _houseNumber.saveToLdap(values); _houseNumberAdd.saveToLdap(values); _city.saveToLdap(values); _postalCode.saveToLdap(values); _street.saveToLdap(values); _country.saveToLdap(values); if(_password.changed()) { _password.saveToLdap(values); #ifndef DEBUG samba::changePassword(_uid().get(), _passwordClearText); #endif } if(values.elms()) { bool roleChanged = _role.changed(); bool classChanged = _schoolClass.changed(); server->modify(_dn(), values); if(isStaff() || isStudent()) { y::Smartschool().saveUser(*this); string message("Updating smartschool for user "); message += _fullName().get(); y::utils::Log().add(message); // add user to group if(isStudent() && classChanged) { // this is a student y::Smartschool().moveUserToClass(*this, _schoolClass().get()); } else if(roleChanged && _role().get() == ROLE::DIRECTOR) { y::Smartschool().addUserToGroup(*this, "Directie", false); } else if (roleChanged && _role().get() == ROLE::SUPPORT) { y::Smartschool().addUserToGroup(*this, "Secretariaat", false); } else if (roleChanged && isStaff()) { y::Smartschool().addUserToGroup(*this, "Leerkrachten", true); } } return true; } if(!_ssPassword.empty()) { y::Smartschool().savePassword(*this); return true; } return false; }
bool Creature::canFlee(bool displayFail, bool checkTimer) { bool crtInRoom=false; long t=0; int i=0; if(isMonster()) { if(!flagIsSet(M_WILL_FLEE) || flagIsSet(M_DM_FOLLOW)) return(false); if(hp.getCur() > hp.getMax()/5) return(false); if(flagIsSet(M_PERMENANT_MONSTER)) return(false); } else { //Player* pThis = getPlayer(); if(!ableToDoCommand()) return(false); if(flagIsSet(P_SITTING)) { if(displayFail) print("You have to stand up first.\n"); return(false); } if(isEffected("hold-person")) { if(displayFail) print("You are unable to move right now.\n"); return(false); } // blah blah re-submit if( (cClass == CreatureClass::BERSERKER || cClass == CreatureClass::CLERIC) && isEffected("berserk") ) { if(displayFail) printColor("^rYour lust for battle prevents you from fleeing!\n"); return(false); } if(checkTimer && !isEffected("fear") && !isStaff()) { t = time(0); i = MAX(getLTAttack(), MAX(lasttime[LT_SPELL].ltime,lasttime[LT_READ_SCROLL].ltime)) + 3L; if(t < i) { if(displayFail) pleaseWait(i-t); return(false); } } // confusion and drunkenness overrides following checks if(isEffected("confusion") || isEffected("drunkenness")) return(true); // players can only flee if someone/something else is in the room for(Monster* mons : getConstRoomParent()->monsters) { if(!mons->isPet()) { crtInRoom = true; break; } } if(!crtInRoom) { for(Player* ply : getConstRoomParent()->players) { if(ply == this) continue; if(!ply->isStaff()) { crtInRoom = true; break; } } } if( !crtInRoom && !checkStaff("There's nothing to flee from!\n") ) { getAsPlayer()->setFleeing(false); return(false); } } return(true); }