123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?php
- namespace loyalsoft;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of GuildModel
- *
- * @author cyzhao
- */
- class GuildModel
- {
- /**
- * 公会的ID
- * @var int
- */
- public $guildId;
- /**
- * 公会名称
- * @var string
- */
- public $name;
- /**
- * 公会的等级
- * @var int
- */
- public $level = 1;
- /**
- * 奖杯积分
- * @var int
- */
- public $cupScore = 0;
- /**
- * 玩家申请加入公会列表
- * @var object
- */
- public $applylist;
- /**
- * 会长的OpenID
- * @var string
- */
- public $chairman_id = "";
- /**
- * 会长 name
- * @var string
- */
- public $chairman_name = "";
- /**
- * @var array 副会长集合
- */
- public $viceChairManArr = array();
- /**
- * @var array 干部
- */
- public $officerManArr = array();
- /**
- * 公会成员
- * @var array
- */
- public $members = array();
- /**
- * 公会的宗旨/公告
- * @var string
- */
- public $declare = "";
- /**
- * 创建时间戳
- * @var type
- */
- public $createts = 0;
- /**
- * 允许一键(快速)加入, 默认不开启
- * @var int
- */
- public $enableQuickIn = 0; //默认允许任何人加入; 1是需要申请;2不允许任何人加入公会
- /**
- * 徽章
- * @var int
- */
- public $guild_img = 0;
- /**
- * 加入公会所需条件
- * @var int
- */
- public $condition;
- /**
- * 弹劾 同意
- * @var type
- */
- public $accuse_agreed = array();
- /**
- * 弹劾 拒接
- * @var type
- */
- public $accuse_refuse = array();
- /**
- * 弹劾 时间
- * @var int
- */
- public $accuseTs = 0;
- /**
- * 弹劾 冷却时间
- * @var int
- */
- public $accuse_coolTime = 0;
- /**
- * 公会总贡献
- * @var int
- */
- public $allContribute = 0;
- /**
- * 公会公告编辑冷却时间
- * @var int
- */
- public $announcement_CoolingTs = 0;
- /**
- * 公会公告内容
- * @var type
- */
- public $announcement_content = array();
- /**
- * 公会礼包购买数量记录
- * @var type
- */
- public $giftnum_record;
- /**
- * 创建新公会
- * @param type $mem
- * @return GuildModel
- */
- public static function NewGuildInit($mem, $zoneid)
- {
- $guildid = self::CreateNewGuildID($mem, $zoneid);
- $guildInfo = new GuildModel();
- $guildInfo->guildId = $guildid;
- $guildInfo->createts = now();
- $guildInfo->members = array();
- $guildInfo->level = 1;
- $guildInfo->cupScore = 0;
- $guildInfo->applylist = ObjectInit();
- $guildInfo->condition = ObjectInit();
- $guildInfo->giftnum_record = ObjectInit();
- return $guildInfo;
- }
- static function CreateNewGuildID($mem, $zoneid)
- {
- $i = 0;
- while (true) {
- if ($mem->add(MemKey_Guild::constCreateGuildIDLock(), "V")) {
- $guildid = $mem->get(MemKey_Guild::constGetCurrentMaxGuildID($zoneid));
- if ($guildid == null) {
- $guildid = GUILDIDBASE;
- }
- $guildid += 1;
- $mem->set(MemKey_Guild::constGetCurrentMaxGuildID($zoneid), $guildid);
- $mem->delete(MemKey_Guild::constCreateGuildIDLock());
- return $guildid;
- } else {
- if ($i++ > 10)
- return 0;
- usleep(13); // 休息13微妙
- }
- }
- }
- }
- /**
- * 玩家请求加入公会的消息结构体
- */
- class UserApplyForGuildModel
- {
- public $uid;
- public $ts;
- public $approved = false;
- public $name;
- public $level;
- /**
- * 创建一条新的请求信息
- * @param type $oid
- * @return UserApplyForGuildModel Description
- */
- public static function CreateApplyInfo($uid, $name, $level)
- {
- $ret = new UserApplyForGuildModel();
- $ret->uid = $uid;
- $ret->ts = now();
- $ret->name = $name;
- $ret->level = $level;
- $ret->approved = false;
- return $ret;
- }
- }
- /**
- * 公会值日消息类型
- */
- class GuildJournalType
- {
- const Join = 1; //加入
- const requestDonate = 2; //请求捐献
- const Quit = 3; //退会
- const ChangeChairMan = 4; //改变会长
- const BuyGift = 5; //购买礼包
- }
- /**
- * 公会日志数据体
- */
- class GuildJournalModel
- {
- public $ts;
- public $uid;
- public $type;
- public $datas;
- public static function CreateJoin($uid, $name)
- {
- $journal = new GuildJournalModel();
- $journal->ts = now();
- $journal->type = GuildJournalType::Join;
- $journal->uid = $uid;
- $journal->datas = array();
- $journal->datas [] = $uid;
- $journal->datas [] = $name;
- return $journal;
- }
- public static function RequestDonate($uid, $name, $cardId, $cardCount)
- {
- $journal = new GuildJournalModel();
- $journal->ts = now();
- $journal->type = GuildJournalType::requestDonate;
- $journal->uid = $uid;
- $journal->datas = array();
- $journal->datas [] = $uid;
- $journal->datas [] = $name;
- $journal->datas [] = $cardId;
- $journal->datas [] = $cardCount;
- $journal->datas [] = 0; //现在已得到的捐献数量
- return $journal;
- }
- public static function CreateQuit($uid, $name)
- {
- $journal = new GuildJournalModel();
- $journal->ts = now();
- $journal->type = GuildJournalType::Quit;
- $journal->uid = $uid;
- $journal->datas = array();
- $journal->datas [] = $uid;
- $journal->datas [] = $name;
- return $journal;
- }
- public static function CreateChangeChairman($uid, $name, $transferedid, $transferedname)
- {
- $journal = new GuildJournalModel();
- $journal->ts = now();
- $journal->type = GuildJournalType::ChangeChairMan;
- $journal->uid = $uid;
- $journal->datas = array();
- $journal->datas [] = $uid;
- $journal->datas [] = $name;
- $journal->datas [] = $transferedid;
- $journal->datas [] = $transferedname;
- return $journal;
- }
- public static function BuyGift($uid, $name)
- {
- $journal = new GuildJournalModel();
- $journal->ts = now();
- $journal->type = GuildJournalType::BuyGift;
- $journal->uid = $uid;
- $journal->datas = array();
- $journal->datas [] = $uid;
- $journal->datas [] = $name;
- return $journal;
- }
- }
- class GuildAnnouncementModel extends Object_ext
- {
- public $ts;
- public $title;
- public $content;
- function __construct($tag, $ts, $title, $content)
- {
- if (1 == func_num_args() && $tag) { # 默认的Object初始化方法
- parent::__construct($tag);
- } else {
- $this->ts = $ts;
- $this->title = $title;
- $this->content = $content;
- }
- }
- }
|