123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- /*
- * @Author: your name
- * @Date: 2021-09-12 12:41:49
- * @LastEditTime: 2021-09-12 17:22:06
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \zombiefood\assets\script\data\Account\AccountModel.ts
- */
- import { USER } from "../../constant/constant-user";
- import IDataModel from "../../framework/data/model/IDataModel";
- import setSearchResolutionsOrder = jsb.fileUtils.setSearchResolutionsOrder;
- import gameEventManager from "../../gameLogic/utrl/gameEventManager";
- import {EVENT_TYPE} from "../../gameLogic/utrl/gameEnum";
- const KEY_ACCOUNT = 'account';
- export default class AccountModel extends IDataModel {
- static singleInstance: AccountModel = null;
- static getInstance(): AccountModel {
- if (AccountModel.singleInstance == null) {
- AccountModel.singleInstance = new AccountModel();
- }
- return AccountModel.singleInstance;
- }
- constructor() {
- super('account');
- }
- initData() {
- //ToDo 第一次游戏
- this.saveValueByKey(USER.CUR_LEVEL, 1); //当前关卡
- this.saveValueByKey(USER.IS_NEW, 1);
- this.saveValueByKey(USER.PLAYER_DATA_LIST, []);
- this.saveValueByKey(USER.CUR_POWER, USER.init_powerNum);
- this.saveValueByKey(USER.CUR_DAY, USER.init_day);
- this.saveValueByKey(USER.CUR_BULLET, USER.init_bulletNum);
- this.saveValueByKey(USER.RELIVE, USER.reLiveNum);
- }
- set reliveNum(data) {
- this.saveValueByKey(USER.RELIVE, data);
- }
- get reliveNum() {
- let data = this.getValueByKey(USER.RELIVE);
- return data;
- }
- set curDay(data) {
- this.saveValueByKey(USER.CUR_DAY, data);
- }
- get curDay() {
- let data = this.getValueByKey(USER.CUR_DAY);
- return data;
- }
- set curBullet(data) {
- this.saveValueByKey(USER.CUR_BULLET, data);
- }
- get curBullet() {
- let data = this.getValueByKey(USER.CUR_BULLET);
- return data;
- }
- set curPower(data) {
- this.saveValueByKey(USER.CUR_POWER, data);
- }
- get curPower() {
- let data = this.getValueByKey(USER.CUR_POWER);
- return data;
- }
- set curKillZomNum(data) {
- this.saveValueByKey(USER.CUR_KILLZOM_NUM, data);
- }
- get curKillZomNum() {
- let data = this.getValueByKey(USER.CUR_KILLZOM_NUM);
- if (!data){
- return 0;
- }
- return data;
- }
- set playerDtList(data) {
- this.saveValueByKey(USER.PLAYER_DATA_LIST, data);
- }
- get playerDtList() {
- let data = this.getValueByKey(USER.PLAYER_DATA_LIST);
- return data;
- }
- get curLevel(): number {
- let level = this.getValueByKey(USER.CUR_LEVEL)
- return level;
- }
- set curLevel(level: number) {
- this.saveValueByKey(USER.CUR_LEVEL, level);
- }
- get is_new(): number {
- let is_new = this.getValueByKey(USER.IS_NEW)
- return is_new;
- }
- set is_new(num: number) {
- this.saveValueByKey(USER.IS_NEW, num);
- }
- get shop_time(): number {
- let shop_time = this.getValueByKey(USER.SHOP_TIME)
- return shop_time;
- }
- set shop_time(num: number) {
- this.saveValueByKey(USER.SHOP_TIME, num);
- }
- get airdrop_time(): number {
- let airdrop_time = this.getValueByKey(USER.AIRDROP_TIME)
- return airdrop_time;
- }
- set airdrop_time(num: number) {
- this.saveValueByKey(USER.AIRDROP_TIME, num);
- }
- get sign_timestamp(): number {
- let sign_timestamp = this.getValueByKey(USER.SIGN_TIMESTAMP)
- return sign_timestamp;
- }
- set sign_timestamp(num: number) {
- this.saveValueByKey(USER.SIGN_TIMESTAMP, num);
- }
- get sign_times(): number {
- let sign_times = this.getValueByKey(USER.SIGN_TIMES);
- if (!sign_times) {
- sign_times = 0;
- }
- return sign_times;
- }
- set sign_times(num: number) {
- this.saveValueByKey(USER.SIGN_TIMES, num);
- }
- get curWelfare(): string[] {
- let tag = this.getValueByKey(USER.WELFARE_TOPIC)
- if (!tag){
- tag = [];
- }
- return tag;
- }
- set curWelfare(tag: string[]) {
- gameEventManager.emit(EVENT_TYPE.OFF_WELFARE_TIP);
- this.saveValueByKey(USER.WELFARE_TOPIC, tag);
- }
- get airdrop_rewards(): string[] {
- let tag = this.getValueByKey(USER.AIRDROP_REWARDS)
- if (!tag){
- tag = [];
- }
- return tag;
- }
- set airdrop_rewards(tag: string[]) {
- this.saveValueByKey(USER.AIRDROP_REWARDS, tag);
- }
- get fixed_role_ids(): number[] {
- let tag = this.getValueByKey(USER.FIXED_ROLE_IDS)
- if (!tag){
- tag = [];
- }
- return tag;
- }
- set fixed_role_ids(tag: number[]) {
- this.saveValueByKey(USER.FIXED_ROLE_IDS, tag);
- }
- get fixed_wp_ids(): number[] {
- let tag = this.getValueByKey(USER.FIXED_WP_IDS)
- if (!tag){
- tag = [];
- }
- return tag;
- }
- set fixed_wp_ids(tag: number[]) {
- this.saveValueByKey(USER.FIXED_WP_IDS, tag);
- }
- get is_airdrop():boolean {
- let tag = this.getValueByKey(USER.IS_AIRDROP)
- if (!tag){
- tag = false;
- }
- return tag;
- }
- set is_airdrop(tag:boolean) {
- this.saveValueByKey(USER.IS_AIRDROP, tag);
- }
- get first_dec_power():boolean {
- let tag = this.getValueByKey(USER.FIRST_DEC_POWER)
- if (!tag){
- tag = false;
- }
- return tag;
- }
- set first_dec_power(tag:boolean) {
- this.saveValueByKey(USER.FIRST_DEC_POWER, tag);
- }
- get first_dec_bullet():boolean {
- let tag = this.getValueByKey(USER.FIRST_DEC_BULLET)
- if (!tag){
- tag = false;
- }
- return tag;
- }
- set first_dec_bullet(tag:boolean) {
- this.saveValueByKey(USER.FIRST_DEC_BULLET, tag);
- }
- get show_crazy_in_level():number {
- let tag = this.getValueByKey(USER.SHOW_CRAZY_IN_LEVEL)
- if (!tag){
- tag = 0;
- }
- return tag;
- }
- set show_crazy_in_level(tag:number) {
- this.saveValueByKey(USER.SHOW_CRAZY_IN_LEVEL, tag);
- }
- getValueByKey(key) {
- return this.Query(key, '');
- }
- saveValueByKey(key, value) {
- this.Set(key, value);
- this.Save();
- }
- /**需要重写 */
- getMessageListeners() {
- return {
- }
- }
- }
|