/** * Created by NICK on 15/10/12. * email:nick121212@126.com * qq:289412378 * copyright NICK */ import cd = require('common/models/common/base_data'); import um = require('common/models/passport/user_model'); export module Brave { export class optionItem extends cd.Common.BaseData { public answer:string; public is_ok:boolean; public doa_words:string; public words:string; public forward_to:number; public piece:string; constructor(data?:any) { super(data); } } export class QuestionOnModel extends cd.Common.BaseData { public questions:Array; public tower:string; public chapter:number; public stage:number; public static _schema = { type: 'object', description: '女神问题', required: [ 'tower', 'chapter', 'stage' ], properties: { tower: { type: 'string', title: '塔' }, chapter: { type: 'number', title: '章节' }, stage: { type: 'number', title: '关卡' } } }; constructor(data?:any) { super(data); } } /* * 一日的勇者问题 * */ export class QuestionModel extends cd.Common.BaseData { public id:number; public title:string; public question:string; public backgroundUrl:string; public tower:string; public chapter:number; public stage:number; public options:Array; public options1:Array; public creator:um.Passport.UserModel; public isRoot:boolean; public series:string; public static _convert(data:any) { var model = new Brave.QuestionModel({ backgroundUrl: data.background_url, createAt: data.created_at, updateAt: data.updated_at, status: data.status, title: data.title, id: data.id, tower: data.tower, chapter: data.chapter_num, stage: data.stage_num, series: data.series, question: data.question, isRoot: data.is_root, options: [], creator: new um.Passport.UserModel({ nickname: data.nickname, userToken: data.user_token, avatarUrl: data.avatar_url }) }); try { data.options = JSON.parse(data.options); data.options.forEach((d)=> { model.options.push(new Brave.optionItem({ answer: d.answer, is_ok: d.is_ok, doa_words: d.doa_words, words: d.words, forward_to: d.forward_to, piece: d.piece })); }); } catch (e) { } return model; } public static _schema = { type: 'object', description: '女神问题', required: [ 'title', 'content', 'location' ], properties: { series: { type: "string", title: "系列" }, question: { type: 'string', title: '问题' }, backgroundUrl: { type: 'string', title: '配图地址' }, isRoot: { type: 'boolean', title: '是否是根题目' }, tower: { type: 'string', title: '塔' }, chapter: { type: 'number', title: '章节' }, stage: { type: 'number', title: '关卡' }, title: { type: 'string', title: '标题' }, options: { type: 'array', title: '选项', items: { type: 'object', properties: { answer: { type: 'string', title: '回答' }, words: { type: 'string', title: '回答后的过渡文本' }, doa_words: { type: 'string', title: '死亡或者存活文本' }, forward_to: { type: 'number', title: '指向下一个问题id' }, is_ok: { type: 'boolean', title: '是否通过', "default": true }, piece: { type: 'string', title: '得到的称号片段' } } } } } }; constructor(data?:any) { super(data); } } }