PlayerData.ts 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import { AccountManager } from "./AccountManager";
  2. //用户user数据
  3. export enum AccountUser{buyed_kun,diamond,equip_themes,favorite_times,game_times,get_themes,list_kun,moeny,progress_themes,revival,stage }
  4. export class PlayerData {
  5. constructor(_token: string, _config: Object, _appSetting: Object, _user: Object, _userbase: Object, _useInvite: any[], _user_stage: Object = null, _user_sign, _user_achievement,lottery) {
  6. this.zhengshu = _token;
  7. //this.peizhis = _config;
  8. this.netzheshe = _appSetting;
  9. this.account = _user;
  10. this.accountssss = _userbase;
  11. this.qiandao = _user_sign;
  12. this.renwu = _user_achievement;
  13. this.userId = this.account["user_id"];
  14. this.openid = this.accountssss["openid"];
  15. this.m_invite = _useInvite;
  16. this.lottery=lottery;
  17. console.log("user_id:" + this.userId);
  18. }
  19. public zhengshu: string;
  20. public peizhis: Object;
  21. public netzheshe: Object;
  22. public account: Object;
  23. public accountssss: Object;
  24. public qiandao: Object;
  25. public renwu: Object;
  26. public openid: string = "";
  27. public userId: string = "";
  28. public m_invite: any[];
  29. public lottery: any;
  30. public GainCollocation(_type: string): any {
  31. return this.peizhis[_type];
  32. }
  33. public GainAccount(_type: string) {
  34. return this.account[_type];
  35. }
  36. public get fenxiang(): boolean {
  37. return this.netzheshe["share"] == "1";
  38. }
  39. public get fenxiangneirong(): string {
  40. return this.netzheshe["sharecontent"];
  41. }
  42. public get fuhuocishu(): number {
  43. return Number(this.netzheshe["revivenum"]);
  44. }
  45. public get wudishijian(): number {
  46. return Number(this.netzheshe["Invincibletime"]);
  47. }
  48. public get wudaoshijian() {
  49. return Number(this.netzheshe["cheattime"]);
  50. }
  51. public get banner(): boolean {
  52. return this.netzheshe["banner"] == "1";
  53. }
  54. public get video(): boolean {
  55. return this.netzheshe["video"] == "1";
  56. }
  57. public get wudao(): boolean {
  58. return this.netzheshe["cheat"] == "1";
  59. }
  60. public get jiancechangjin(): boolean {
  61. return this.netzheshe["checkscence"] == 1;
  62. }
  63. public get reviverate(): number {
  64. return Number(this.netzheshe["revive"]);
  65. }
  66. public get uintid() {
  67. return this.netzheshe["uintid"];
  68. }
  69. public get music(): boolean {
  70. return this.netzheshe["music"] == "1";
  71. }
  72. public get skin(): boolean {
  73. return this.netzheshe["skinget"] == "1";
  74. }
  75. public get aicheatspeed(): number {
  76. return Number(this.netzheshe["aicheatspeed"]);
  77. }
  78. public get aispeedtime(): number {
  79. return Number(this.netzheshe["aispeedtime"]);
  80. }
  81. public get videoshare(): boolean {
  82. return this.netzheshe["videoshare"] == "1";
  83. }
  84. public get trial(): boolean {
  85. return this.netzheshe["trial"] == "1";
  86. }
  87. public get invite(): boolean {
  88. return this.netzheshe["invite"] == 1;
  89. }
  90. public get re(): boolean {
  91. return this.netzheshe["re"] == 1;
  92. }
  93. public get autosign(): boolean {
  94. return this.netzheshe["autosign"] == 1;
  95. }
  96. public get showgift(): boolean {
  97. return this.netzheshe["showgift"] == 1;
  98. }
  99. public get showshop(): boolean {
  100. return this.netzheshe["showshop"] == 1;
  101. }
  102. public get lotteryTimer(): Number {
  103. if(this.netzheshe["lotteryTimer"]) return Number(this.netzheshe["lotteryTimer"]);
  104. return 0;
  105. }
  106. //获取高度线
  107. public get falldownline():number{
  108. return this.netzheshe["FallDownLine"];
  109. }
  110. //获取球的弹性值
  111. public get Restitution():number{
  112. return this.netzheshe["restitution"];
  113. }
  114. //获取球合成的速度
  115. public get MergeSpeed():number{
  116. return this.netzheshe["MergeSpeed"]
  117. }
  118. //获取失败检测的时间间隔
  119. public get CheckLose():number{
  120. return this.netzheshe["CheckLose"]
  121. }
  122. //获取存档的时间间隔
  123. public get Save():number{
  124. return this.netzheshe["Save"]
  125. }
  126. //获取新手指引关高度线
  127. public get GuideHeight():number{
  128. return this.netzheshe["GuideHeight"]
  129. }
  130. //获取震动消除数量
  131. public get ShakeNum():number{
  132. return this.netzheshe["ShakeNum"];
  133. }
  134. //获取球球之间的消除间隔距离
  135. public get Distance():number{
  136. return this.netzheshe["Distance"]
  137. }
  138. //获取球的溢出线
  139. public get OverRun():number{
  140. return this.netzheshe["OverRun"]
  141. }
  142. public get touchsize():number
  143. {
  144. return Number(this.netzheshe["touchsize"]);
  145. }
  146. public get touchsmoothness():number
  147. {
  148. return Number(this.netzheshe["touchsmoothness"]);
  149. }
  150. public jianglidic: { [key: string]: any } = {};
  151. public shitidic: { [key: string]: any } = {};
  152. public chengjiuliebiao: { [key: string]: any } = {};
  153. public GainQinDao(_key: string) {
  154. return this.qiandao[_key];
  155. }
  156. public GainShiTi(_key: string, shuxing: string) {
  157. return this.shitidic[_key][shuxing];
  158. }
  159. public GainJiangLi(_rewardid: number): any {
  160. var reward = this.jianglidic[_rewardid];
  161. return reward;
  162. }
  163. //获取各道具数量
  164. public GetPropNum(_index:number) {
  165. var type = this.account["functions"];
  166. var num = type[_index.toString()];
  167. if(num){
  168. return num
  169. }
  170. else{
  171. return 0;
  172. }
  173. }
  174. /** 判断玩家是否含有角色*/
  175. public HasRole(_id: number): boolean {
  176. var data = this.GainAccount("get_themes");
  177. for (var i = 0; i < data.length; i++) {
  178. var hd = data[i];
  179. if (_id == hd) {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. /** 判断玩家是否含有枪械*/
  186. public HasGun(_id: number): boolean {
  187. var data = this.GainAccount("functions");
  188. for (var i = 0; i < data.length; i++) {
  189. var hd = data[i];
  190. if (_id ==hd ) {
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. /**返回玩家看视频获得角色及枪械的进度 */
  197. public GetProgress(_id:number):number{
  198. var config = this.account["progress_themes"];
  199. var progress = config[_id] ? config[_id] : 0;
  200. return progress;
  201. }
  202. GetJiangLiLieBiao() {
  203. var peiz = this.GainCollocation("rewards");
  204. for (var key in peiz) {
  205. this.jianglidic[peiz[key].id] = peiz[key];
  206. }
  207. }
  208. GetShiTiLieBiao() {
  209. var peiz = this.GainCollocation("entity");
  210. for (var key in peiz) {
  211. this.shitidic[peiz[key].entity_id] = peiz[key];
  212. }
  213. }
  214. GetChengJiuLieBiao() {
  215. var shujiu = this.GainCollocation("achievement");
  216. var aadsadsdas = {};
  217. for (var key1 in shujiu) {
  218. var type1 = shujiu[key1].type;
  219. //var obj = {};
  220. if (aadsadsdas[type1]) {
  221. continue;
  222. }
  223. var fasas = [];
  224. for (var key2 in shujiu) {
  225. var type2 = shujiu[key2].type;
  226. if (type1 == type2) {
  227. fasas.push(shujiu[key2]);
  228. }
  229. }
  230. aadsadsdas[type1] = fasas;
  231. }
  232. this.chengjiuliebiao = aadsadsdas;
  233. }
  234. }