예제 #1
0
파일: scenario.py 프로젝트: Sayya/trpg
    def class_out(cls):
        # インポート部分
        from basemods import Holder

        classts = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role')

        Scenario.candi = [Holder.classt(c) for c in classts]

        return (Scenario.candi, 'クラスを選んでください', True)
예제 #2
0
파일: event.py 프로젝트: Sayya/trpg
    def focus_out_obj_role(self):
        # インポート部分
        from basemods import Holder
        from game import Game

        role_f = self.role_f()
        objrole_m_str = self.objrole_m_str()

        rtn = Game.dummy()

        # 受動ロールの設定
        if objrole_m_str == '':
            if role_f in (2, 3):
                rtn = (Holder.master('Role').values(), 'Arbit', 'Role', 0)
            else:
                self.objrole = self.role_first
        else:
            self.objrole = Holder.master('Role', objrole_m_str)

        return rtn
예제 #3
0
파일: process.py 프로젝트: Sayya/trpg
    def buildvalid(self):
        # インポート部分
        from basemods import Holder
        from iotemp import Template

        # Param.name のテンプレート処理 - scala編
        if self.gtarget not in Holder.master('Param').keys():
            try:
                self.gtarget = Template.holder[self.group][Holder.classt('Param')][self.gtarget]
            except Exception:
                print('TEMPLATEERROR: Process.gtarget -{0}-'.format(self.name))

        # Param.name のテンプレート処理 - scala編
        if self.gsbj_param not in Holder.master('Param').keys():
            try:
                self.gsbj_param = Template.holder[self.group][Holder.classt('Param')][self.gsbj_param]
            except Exception:
                print('TEMPLATEERROR: Process.gsbj_param -{0}-'.format(self.name))
                
        # Param.name のテンプレート処理 - scala編
        if self.gobj_param not in Holder.master('Param').keys():
            try:
                self.gobj_param = Template.holder[self.group][Holder.classt('Param')][self.gobj_param]
            except Exception:
                print('TEMPLATEERROR: Process.gobj_param -{0}-'.format(self.name))
예제 #4
0
파일: event.py 프로젝트: Sayya/trpg
    def buildvalid(self):
        # インポート部分
        from basemods import Holder
        from iotemp import Template

        # Process.name のテンプレート処理 - scala編
        if self.procs not in Holder.master('Process').keys():
            try:
                self.procs = Template.holder[self.group][Holder.classt(
                    'Process')][self.procs]
            except Exception:
                print('TEMPLATEERROR: Event.procs')

        lis_role = list(self.role)
        for v in lis_role:
            # Role.name のテンプレート処理 - tuple編
            if v not in Holder.master('Role').keys():
                idx = lis_role.index(v)
                del lis_role[idx]
                try:
                    tname1 = Template.holder[self.group][Holder.classt(
                        'Role')][v]
                except Exception:
                    tname1 = ''
                    print('TEMPLATEERROR: Event.role -{0}- v={1}, idx={2}'.
                          format(self.name, v, idx))
                lis_role.insert(idx, tname1)
        self.role = tuple(lis_role)

        lis_thing = list(self.thing)
        for v in lis_thing:
            # Thing.name のテンプレート処理 - tuple編
            if v not in Holder.master('Thing').keys():
                idx = lis_thing.index(v)
                del lis_thing[idx]
                try:
                    tname2 = Template.holder[self.group][Holder.classt(
                        'Thing')][v]
                except Exception:
                    tname2 = ''
                    print('TEMPLATEERROR: Event.thing -{0}- v={1}, idx={2}'.
                          format(self.name, v, idx))
                lis_thing.insert(idx, tname2)
        self.thing = tuple(lis_thing)

        if len(self.role) != 2:
            raise TrpgError('引数 -{0}- のリストサイズが2ではありません'.format('role'))
        if len(self.thing) != 2:
            raise TrpgError('引数 -{0}- のリストサイズが2ではありません'.format('thing'))
예제 #5
0
    def action_in(self, act):
        """ Request In """
        # インポート部分
        from basemods import Holder

        if act is None:
            act = self.getroutes()[0]
        self.act = act

        if type(act) is Holder.classt('Route'):
            return {
                'curr_func': self.way_node,
                'arg': (act, ),
                'next_func': self.way_in
            }
        else:
            return {
                'curr_func': self.focus_out_thing,
                'arg': (),
                'next_func': self.focus_in_thing
            }
예제 #6
0
    def check_in(self, s_name, tmpl, desc, opted):
        # インポート部分
        from basemods import Holder
        
        tmpls = tmpl.split('-')

        typet = tmpls[0]
        numbt = None 
        if len(tmpls) > 1:
            numbt = int(tmpls[1]) # tuple 定数a, list 無制限=0, dict 無制限=0の場合
            if numbt < 1 or 100 < numbt:
                numbt = 100

        if typet == 'str':
            if s_name == 'name':
                if self.name != '':
                    rtn = self.name
                else:
                    rtn = opted
                
                # 更新の場合
                if rtn in list(self.classt.master.keys()):
                    self.existclss = self.classt.master[rtn]
            else:
                rtn = opted
        elif typet == 'int':
            try:
                rtn = int(opted)
            except ValueError as e:
                if Dice.checkdice(rtn) > 0:
                    print('MESSAGE: ダイス形式で設定')
                    rtn = opted
                else:
                    print('Exception: {0}'.format(e))
                    rtn = 0
        elif typet == 'bool':
            rtn = bool(opted)
        elif typet == 'tuple':
            self.tlis = list(opted)
            rtn = tuple(self.tlis)
        elif typet == 'list':
            self.tlis = list(opted)
            rtn = self.tlis
        elif typet == 'dict':
            keyt = opted
            valt = opted
                
            self.tlis.append((keyt, valt))
            rtn = dict(self.tlis)
        else:
            rtn = opted
            tt = typet.split('.')
            classtnames = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role')
            if tt[0] in classtnames:
                s_classt = Holder.classt(tt[0])
                if tt[1] == 'name':
                    s_candi = list(s_classt.master.keys())
                elif tt[1] == 'deed':
                    gg = getmembers(s_classt, isfunction)
                    s_candi = [g[0] for g in gg]

                if tt[1] == 'name' and rtn not in s_candi:
                    t = Template(s_classt, self.group, rtn)
                    print('グループ -{0}- > クラス -{1}- > テンプレート -{2}- を作成しました'.format(self.group, s_classt.__name__, rtn))
                    t.holdermap(self.group, s_classt, rtn)
        
        if self.existclss is not None:
            if rtn == '':
                default = getattr(self.existclss, s_name)
                if type(default) in (int, str, bool):
                    rtn = default
                else:
                    raise TrpgError('デフォルトを設定します')

            setattr(self.existclss, s_name, rtn)
예제 #7
0
    def check_out(self, s_name, tmpl, desc):
        # インポート部分
        from basemods import Holder

        def outputu(desc, typet, candi=list(), numbt=None):
            default = None
            try:
                if self.existclss is not None:
                    default = getattr(self.existclss, s_name)
                    # message = '{0}({1}): {2} (default: {3})'.format(desc, s_name, typet, default)

                # (型, 候補リスト, 繰り返し回数, 入力領域, デフォルト)
                return (typet, candi, numbt, list(), default)
            except TrpgError as e:
                raise e
        
        tmpls = tmpl.split('-')

        typet = tmpls[0]
        valut = ''
        numbt = None 
        if len(tmpls) > 1:
            numbt = int(tmpls[1]) # tuple 定数a, list 無制限=0, dict 無制限=0の場合
            if numbt < 1 or 100 < numbt:
                numbt = 100
            valut = '-'.join(tmpls[2:])

        if typet == 'str':
            if s_name == 'name':
                if self.name == '':
                    print('UPDATE IN {0}'.format(list(self.classt.master.keys())))
                return outputu(desc, typet)
            else:
                return outputu(desc, typet)
        elif typet == 'int':
            return outputu(desc, typet)
        elif typet == 'bool':
            return outputu(desc, typet)
        elif typet == 'tuple':
            return outputu(desc, 'tuple', self.check_out(s_name, valut, desc), numbt)
        elif typet == 'list':
            return outputu(desc, 'list', self.check_out(s_name, valut, desc), numbt)
        elif typet == 'dict':
            tt = valut.split(':')
            tt0 = self.check_out(s_name, tt[0], desc)
            tt1 = self.check_out(s_name, tt[1], desc)
            return outputu(desc, 'dict', (tt0, tt1), numbt)
        else:
            tt = typet.split('.')
            classtnames = ('Param', 'Thing', 'Process', 'Event', 'Route', 'Role')
            if tt[0] in classtnames:
                s_classt = Holder.classt(tt[0])
                if tt[1] == 'name':
                    s_candi = list(s_classt.master.keys())
                elif tt[1] == 'deed':
                    gg = getmembers(s_classt, isfunction)
                    s_candi = [g[0] for g in gg]

                print('SELECT IN {0}'.format(s_candi))

                return outputu(desc, typet, s_candi)
예제 #8
0
    __package__ = 'trpg'
    print('__package__: {}, __name__: {}'.format(__package__, __name__))

    Test()
    Game(['太郎'])

    while True:
        print('SELECT IN {0}'.format({0: 'wizard', 1: 'game'}))
        start = input('> ')

        #        try:
        if start == '0':
            s_argdic = Scenario.argdic_first()
            while True:
                wiz_out = Holder.progr_out(s_argdic)

                if wiz_out[2] is None:
                    break

                try:
                    if not wiz_out[2]:
                        # 自由に入力
                        if wiz_out[0] is None:
                            raise TrpgError('選択肢しませんでした')
                        print('UPDATE IN {0}'.format(wiz_out[0]))
                        wiz_in = input('{0} > '.format(wiz_out[1]))
                    else:
                        # リストからの選択
                        s_candi = Arbit.input_out(wiz_out[0], 'Scenario',
                                                  'make')
예제 #9
0
파일: event.py 프로젝트: Sayya/trpg
    def do(self, n):
        # インポート部分
        from basemods import Holder

        return Holder.master('Process', self.procs).deed(self.sbj, self.obj, n)
예제 #10
0
파일: event.py 프로젝트: Sayya/trpg
    def objthing_m(self):
        # インポート部分
        from basemods import Holder

        return Holder.master('Thing', self.thing[1])
예제 #11
0
    def getpropts(self):
        # インポート部分
        from basemods import Holder

        return [Holder.master('Thing', i) for i in self.propts]
예제 #12
0
파일: process.py 프로젝트: Sayya/trpg
 def obj_param(self):
     # インポート部分
     from basemods import Holder
     
     return Holder.master('Param', self.gobj_param)
예제 #13
0
파일: process.py 프로젝트: Sayya/trpg
    def target(self):
        # インポート部分
        from basemods import Holder

        return Holder.master('Param', self.gtarget)