Пример #1
0
    def setUp(self):


        self.logger = create_ifind_logger('test_game_achievements.log')

        #print "Setting up Game Achievements for Player Test"
        self.logger.info("Setting up Game Achievemtns for Player Test.")
        User.objects.get_or_create(username='******', password='******')
        self.u = User.objects.get(username='******')
        UserProfile.objects.get_or_create(user=self.u)

        Category.objects.get_or_create(name='Numbers', desc='Looking for sites that about numbers')
        self.c = Category.objects.get(name='Numbers')
        for pn in ['one','two','three','four']:
            Page.objects.get_or_create(category=self.c, title=pn, url='www.'+pn+'.com', snippet=pn, desc=('desc: ' +pn))

        Category.objects.get_or_create(name='Letters', desc='Looking for sites that  about letters')
        self.c1 = Category.objects.get(name='Letters')
        self.assertEquals(len(Category.objects.all()), 2)

        #------------
        for name in ['1', '2', '3', '4', '5', '6']:
            Category.objects.get_or_create(name=name, desc='Looking for sites that  about {0}'.format(name))

        Achievement.objects.get_or_create(name="HighScorer", desc='',xp_earned=10000, achievement_class='HighScorer')
        self.allcat = Achievement.objects.get_or_create(name="AllCat", desc='', xp_earned=500, achievement_class='AllCat')
        Achievement.objects.get_or_create(name="FivePagesInAGame", desc='', xp_earned=7, achievement_class='FivePagesInAGame')
        Achievement.objects.get_or_create(name="TenGamesPlayed", desc='', xp_earned=7, achievement_class='TenGamesPlayed')
        Achievement.objects.get_or_create(name="UberSearcher", desc='', xp_earned=7, achievement_class='UberSearcher')

        self.p = Page.objects.all()[0]
        self.cg = CurrentGame(category=self.c, current_page=self.p, user=self.u)
        self.up = UserProfile.objects.get(user=self.u)
        self.gac = GameAchievementChecker(self.u)
Пример #2
0
    def setUp(self):

        self.logger = create_ifind_logger('test_game_achievements.log')

        #print "Setting up Game Achievements for Player Test"
        self.logger.info("Setting up Game Achievemtns for Player Test.")
        User.objects.get_or_create(username='******', password='******')
        self.u = User.objects.get(username='******')
        UserProfile.objects.get_or_create(user=self.u)

        Category.objects.get_or_create(
            name='Numbers', desc='Looking for sites that about numbers')
        self.c = Category.objects.get(name='Numbers')
        for pn in ['one', 'two', 'three', 'four']:
            Page.objects.get_or_create(category=self.c,
                                       title=pn,
                                       url='www.' + pn + '.com',
                                       snippet=pn,
                                       desc=('desc: ' + pn))

        Category.objects.get_or_create(
            name='Letters', desc='Looking for sites that  about letters')
        self.c1 = Category.objects.get(name='Letters')
        self.assertEquals(len(Category.objects.all()), 2)

        #------------
        for name in ['1', '2', '3', '4', '5', '6']:
            Category.objects.get_or_create(
                name=name,
                desc='Looking for sites that  about {0}'.format(name))

        Achievement.objects.get_or_create(name="HighScorer",
                                          desc='',
                                          xp_earned=10000,
                                          achievement_class='HighScorer')
        self.allcat = Achievement.objects.get_or_create(
            name="AllCat", desc='', xp_earned=500, achievement_class='AllCat')
        Achievement.objects.get_or_create(name="FivePagesInAGame",
                                          desc='',
                                          xp_earned=7,
                                          achievement_class='FivePagesInAGame')
        Achievement.objects.get_or_create(name="TenGamesPlayed",
                                          desc='',
                                          xp_earned=7,
                                          achievement_class='TenGamesPlayed')
        Achievement.objects.get_or_create(name="UberSearcher",
                                          desc='',
                                          xp_earned=7,
                                          achievement_class='UberSearcher')

        self.p = Page.objects.all()[0]
        self.cg = CurrentGame(category=self.c,
                              current_page=self.p,
                              user=self.u)
        self.up = UserProfile.objects.get(user=self.u)
        self.gac = GameAchievementChecker(self.u)
Пример #3
0
    def setUp(self):
        self.logger = create_ifind_logger("game_mechanic_test.log")
        print "Setting up Game Mechanic Test"
        User.objects.get_or_create(username='******', password='******')
        self.u = User.objects.get(username='******')
        UserProfile.objects.create(user=self.u)
        Category.objects.get_or_create(
            name='Numbers', desc='Looking for sites that around about numbers')

        c = Category.objects.get(name='Numbers')
        for pn in ['one','two','three','four']:
            Page.objects.get_or_create(category=c, title=pn,
                                       url='www.'+pn+'.com', snippet=pn,
                                       desc=('desc: ' +pn))
Пример #4
0
    def setUp(self):
        self.logger = create_ifind_logger("game_mechanic_test.log")
        print "Setting up Game Mechanic Test"
        User.objects.get_or_create(username='******', password='******')
        self.u = User.objects.get(username='******')
        UserProfile.objects.create(user=self.u)
        Category.objects.get_or_create(
            name='Numbers', desc='Looking for sites that around about numbers')

        c = Category.objects.get(name='Numbers')
        for pn in ['one', 'two', 'three', 'four']:
            Page.objects.get_or_create(category=c,
                                       title=pn,
                                       url='www.' + pn + '.com',
                                       snippet=pn,
                                       desc=('desc: ' + pn))
Пример #5
0
from ifind.common.setuplogger import create_ifind_logger

logger = create_ifind_logger('log')
Пример #6
0
def main():

    logger = create_ifind_logger('test_game_mech.log')
    logger.info("Program started")
    logger.info('Testing game mechanics')

    print "This script is to test the GameMechanics and interaction with the Models"

    ds = EngineFactory("Dummy")

    gm = GameMechanic(ds)
    print gm
    u = User.objects.filter(username='******')
    if u:
        u = u[0]
    else:
        print "Adding testy user"
        u = User(username='******', password='******')
        u.save()

    c = Category.objects.filter(name='Numbers')

    if c:
        c = c[0]
    else:
        print "Adding a Numbers Category"
        c = Category(name='Numbers',
                     desc='Looking for sites that around about numbers')
        c.save()

    pages = Page.objects.filter(category=c)

    if not pages:
        print "Adding pages"

        for pn in ['one', 'two', 'three', 'four']:
            p = Page(category=c,
                     title=pn,
                     url='www.' + pn + '.com',
                     snippet=pn,
                     desc=('desc: ' + pn))
            p.save()

        pages = Page.objects.filter(category=c)

    print u
    print c
    print pages

    gm.create_game(u, c)

    print gm

    print "Game is set up to play"
    raw_input('Press enter to continue')

    while not gm.is_game_over():
        clear_screen()
        print gm
        last_query = gm.get_last_query()
        if last_query:
            print "\nLast Query: %s and Query Score: %d" % (
                last_query, gm.get_last_query_score())
        state = handle_game_input()
        if state == 1:
            gm.take_points()
            gm.set_next_page()
            state = 0
        if state == 2:
            query = handle_query_input()
            gm.handle_query(query)

    print '\nGame Over!!\n'
    print gm
    logger.info("Done!")
Пример #7
0
from ifind.common.setuplogger import create_ifind_logger
logger = create_ifind_logger('log')
Пример #8
0
 def setUp(self):
     User.objects.get_or_create(username='******', password='******')
     self.logger = create_ifind_logger('game_model_teset.log')
Пример #9
0
def main():

    logger = create_ifind_logger("test_game_mech.log")
    logger.info("Program started")
    logger.info("Testing game mechanics")

    print "This script is to test the GameMechanics and interaction with the Models"

    ds = EngineFactory("Dummy")

    gm = GameMechanic(ds)
    print gm
    u = User.objects.filter(username="******")
    if u:
        u = u[0]
    else:
        print "Adding testy user"
        u = User(username="******", password="******")
        u.save()

    c = Category.objects.filter(name="Numbers")

    if c:
        c = c[0]
    else:
        print "Adding a Numbers Category"
        c = Category(name="Numbers", desc="Looking for sites that around about numbers")
        c.save()

    pages = Page.objects.filter(category=c)

    if not pages:
        print "Adding pages"

        for pn in ["one", "two", "three", "four"]:
            p = Page(category=c, title=pn, url="www." + pn + ".com", snippet=pn, desc=("desc: " + pn))
            p.save()

        pages = Page.objects.filter(category=c)

    print u
    print c
    print pages

    gm.create_game(u, c)

    print gm

    print "Game is set up to play"
    raw_input("Press enter to continue")

    while not gm.is_game_over():
        clear_screen()
        print gm
        last_query = gm.get_last_query()
        if last_query:
            print "\nLast Query: %s and Query Score: %d" % (last_query, gm.get_last_query_score())
        state = handle_game_input()
        if state == 1:
            gm.take_points()
            gm.set_next_page()
            state = 0
        if state == 2:
            query = handle_query_input()
            gm.handle_query(query)

    print "\nGame Over!!\n"
    print gm
    logger.info("Done!")
Пример #10
0
 def setUp(self):
     User.objects.get_or_create(username='******', password='******')
     self.logger = create_ifind_logger('game_model_teset.log')