Beispiel #1
0
 def doCommand(data, args):
     if (len(args) % 2 != 0):
         print('ERROR: Please have one argument for each command')
         return
     query_args = []
     query_arg_vals = []
     i = 0
     allowed_args = {
         'name', 'dynasty', 'ismale', 'birthday', 'deathday', 'father',
         'real_father', 'mother', 'religion', 'culture', 'fertility',
         'health', 'wealth', 'prestige', 'piety'
     }
     valid = True
     while i < len(args):
         if (args[i] in allowed_args):
             query_args.append(args[i])
             query_arg_vals.append(args[i + 1])
         else:
             print(
                 'ERROR: ' + args[i] +
                 ' is not a valid condition, please use one of the following values:'
             )
             print(allowed_args)
             return
         i += 2
     #get person with these conditions
     headings = [
         'ID', 'Name', 'Dynasty', 'is Male', 'Birthday', 'Deathday',
         'Father', 'Real Father', 'Mother', 'Religion', 'Culture',
         'Fertility', 'Health', 'Wealth', 'Prestige', 'Piety'
     ]
     query_result = data.query_person(query_args, query_arg_vals)
     table_print(query_result, headings)
Beispiel #2
0
    def doCommand(data,args):
        query_result = None
        headings = None

        query_args = []
        if(len(args)%2 != 0):
            print('ERROR: Please have one argument for each command')
            return
        query_arg_vals = []
        i = 0
        allowed_args = {'bloodlinename', 'founderid'}
        valid = True
        while i < len(args):
            if(args[i] in allowed_args):
                query_args.append(args[i])
                query_arg_vals.append(args[i+1])
            else:
                print('ERROR: ' + args[i] + ' is not a valid condition, please use one of the following values:')
                print(allowed_args)
                valid = False
            i += 2
        if valid:
            headings = ['ID', 'Type', 'Founder']
            query_result = data.query_bloodline(query_args,query_arg_vals)
            table_print(query_result,headings)
 def doCommand(data, args):
     if (len(args) != 1):
         print(
             'ERROR: bloodline_members takes one argument (the id of the bloodline) and one argument only'
         )
     else:
         headings = ['Name', 'Dynasty']
         query_result = data.query_bloodline_members(args[0])
         table_print(query_result, headings)
Beispiel #4
0
 def doCommand(data, args):
     query_result = None
     headings = None
     if len(args) == 0:
         headings = ['Culture']
         query_result = data.query_culture()
     elif len(args) == 1:
         headings = ['Culture', 'Number']
         valid_args = {'allmembers', 'alivemembers', 'provinces'}
         if args[0] not in valid_args:
             print('Invalid argument. Try one of:')
             print(valid_args)
             return
         query_result = data.query_culture(args[0])
     else:
         print('ERROR: Too many arguments.')
         return
     table_print(query_result, headings)
Beispiel #5
0
 def doCommand(data, args):
     if (len(args) % 2 != 0):
         print('ERROR: Please have one argument for each command')
         return
     query_args = []
     query_arg_vals = []
     i = 0
     allowed_args = {'name', 'orderby', 'religion', 'culture'}
     valid = True
     has_orderby = False
     while i < len(args):
         if (args[i] in allowed_args):
             valid_vals = {'prestige', 'piety', 'wealth', 'count'}
             if args[i] == 'orderby':
                 if has_orderby:
                     valid = False
                     print(
                         'ERROR: Query contained a second orderby term. Queries should contain zero or one orderby term.'
                     )
                     break
                 has_orderby = True
                 if args[i + 1] not in valid_vals:
                     print(
                         'ERROR: ' + args[i + 1] +
                         ' is not a valid value to order by. Please use one of:'
                     )
                     print(valid_vals)
                     valid = False
             if valid:
                 query_args.append(args[i])
                 query_arg_vals.append(args[i + 1])
         else:
             print(
                 'ERROR: ' + args[i] +
                 ' is not a valid condition, please use one of the following values:'
             )
             print(allowed_args)
             valid = False
         i += 2
     #get person with these conditions
     if valid:
         query_result = data.query_dynasty(query_args, query_arg_vals)
         table_print(query_result)
Beispiel #6
0
 def doCommand(data, args):
     query_result = None
     headings = None
     # title on its own returns ???
     if len(args) == 0:
         print(
             'Title queries should be of the form : title personid or title rulers titleid or title current titleid'
         )
         return
     # title id returns all titles of the given personid
     elif len(args) == 1:
         query_result = data.query_title(args[0])
         headings = ['Title ID']
     # we are looking for personID(s) given a certain title
     elif len(args) == 2:
         #rulers
         if args[0] == 'rulers':
             query_result = data.query_rulers(args[1])
             headings = [
                 'personid', 'Name', 'Dynasty', 'Date of Birth',
                 'Date of Death', 'Start of Rule'
             ]
         #current
         elif args[0] == 'current':
             query_result = data.query_ruler(args[1])
             headings = ['personid', 'Name', 'Dynasty']
         else:
             print(
                 "Queries should be of the form 'title (rulers|current) titleid.'"
             )
             return
     else:
         print(
             'Title queries should be of the form : title personid or title rulers titleid or title current titleid'
         )
         return
     table_print(query_result, headings)