예제 #1
0
def customProfiles():
    _customProfiles = []
    profileFiles = customProfileFiles()
    for f in profileFiles:
        profile = Profile.fromFile(f)
        _customProfiles.append(profile)
    return _customProfiles
예제 #2
0
def customProfiles():
    _customProfiles = []
    profileFiles = customProfileFiles()
    for f in profileFiles:
        profile = Profile.fromFile(f)
        _customProfiles.append(profile)
    return _customProfiles
예제 #3
0
    def main_next(self):

        if self.check_probs():
            self.profile.information['case'] += 1
            self.case += 1
            self.fix_probs()
        self.profile.save(self.save_dir)
        self.profile = Profile() if not os.path.exists(
            self.save_dir) else Profile.read_save(self.save_dir)

        # if self.case == 8:
        # cutscene = Cutscene(self.director, 2)
        # self.director.replace(cutscene)
        # else:
        # if victory:
        self.remove(self.MGLayer.ch_layer)
        self.scroller.remove(self.MGLayer)
        # instantiate new Main Game Layer
        self.MGLayer = MainGameLayer(self.director, self.scroller, self,
                                     self.case, self.profile, self.dna)
        self.scroller.add(self.MGLayer, z=1)
        self.director.pop()
예제 #4
0
def main():
    banner("2.3")
    # hr = "------------------------------------"
    # counter below needs to be added as part of the Sheepl Object
    # this should get automatically incremented either based on the
    # length of the task list or a counter tracker
    # Main Parser Setup
    args = parse_arguments()

    # create project root
    #ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

    # assign colour output
    colour_output = args.no_colour
    print("[!] Colour output is set to : {}".format(
        str(colour_output).upper()))
    cl = ColourText(colour_output)
    tasks = Tasks()

    # gets global header declarations for autoIT script
    # >> Global Calls

    # manual check for Interactive
    if args.interactive:
        interactive = True
        context = ConsoleContext()
        con = SheeplConsole(context, cl, tasks)
        con.cmdloop()

    # template functions need updating for the stub code so commenting out this feature for now.
    # will fix in next push
    # Check if creating template stub file and category.
    # this should be replaced with pathlib functions
    #if args.template and not args.category:
    #    print(cl.red("[!] You must specify a category eg 'network'"))
    #    print("[>] If this path does not exist, then it will be created")

    #elif args.template:
    #    if not os.path.isdir('tasks/' + args.category.lower()):
    #        print(cl.yellow("[!] Couldn't find this category : " + args.category.lower()))
    #        print(cl.green("[!] Creating {} category path now.".format(args.category.lower())))
    #        os.mkdir('tasks/' + args.category.lower())
    #    else:
    #        print("[>] Category already Exists : " + cl.red("tasks/" + args.category.lower()))
    #        os.chdir('tasks/' + args.category.lower())
    #        if not os.path.isfile(args.template + '.py'):
    #            print("[!] Creating task template: {}".format(cl.green(args.template)))
    #            CreateTemplate(args.template)

    #        if os.path.isfile(args.template + '.py'):
    #            print(cl.red("[!] Task template already exists : " + args.template))
    #            # spam loop until yes or no is answered
    #            while 1:
    #                replace_template = input("[?] Do you want to replace this file? <yes> <no> : ")
    #                if replace_template.lower() == "yes" or replace_template.lower() == "no":
    #                    break
    #            if replace_template.lower() == "yes":
    #                print("[!] Creating new task template : " + cl.green(args.template + '.py'))
    #                CreateTemplate(args.template)
    #            else:
    #                print(cl.green("[!] Leaving orginal template intact"))

    # create from JSON profile
    if args.profile:
        print("[!] Create a sheepl from the profile file : {}".format(
            cl.green(args.profile.name)))
        # Set Interactive to False
        interactive = False
        Profile(cl, args.profile.name, tasks)
예제 #5
0
    def __init__(self, director, state):

        self.director = director
        self.state = state

        self.dna = GameBackground('../res/main_game_backgrounds/main.png')
        # self.bg = GameBackground('../res/main_game_backgrounds/background.png')

        super().__init__()

        self.save_dir = 'profiles/save.json'
        if self.state == 'newgame':
            self.profile = Profile()
        else:
            self.profile = Profile() if not os.path.exists(
                self.save_dir) else Profile.read_save(self.save_dir)

        self.popups = {}
        self.shown_popup = None
        # for name in os.
        self.popups['finish_helicase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_helicase.png'),
            position=(640, 360))
        self.popups['fail_helicase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_helicase.png'),
            position=(640, 360))
        self.popups['finish_pp'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_pp.png'),
            position=(640, 360))
        self.popups['fail_pp'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_pp.png'),
            position=(640, 360))
        self.popups['finish_ligase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_ligase.png'),
            position=(640, 360))
        self.popups['fail_ligase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_ligase.png'),
            position=(640, 360))

        for pop in self.popups.values():
            self.add(pop, 4)
            pop.do(Hide())

        self.case = self.profile.information['case']

        self.pos = [600, 0]

        self.life_num = self.profile.get_lives()
        print('new life number', self.life_num)
        self.lives = cocos.sprite.Sprite(
            pyglet.image.load('../res/lives_' + str(self.life_num) + '.png'),
            position=(224, 637))

        self.scroller = cocos.layer.ScrollingManager()
        self.MGLayer = MainGameLayer(self.director, self.scroller, self,
                                     self.case, self.profile, self.dna)

        back_button = Button(1199, 658, '../res/back_button.png', self,
                             self.back)
        back_button.setHasHighlight('../res/back_button_h.png')

        left_button = Button(1050, 90, '../res/BUTTON LEFT.png', self,
                             self.set_pos_left)
        left_button.setHasHighlight('../res/BUTTON LEFT HIGHLIGHTED.png')
        right_button = Button(1190, 90, '../res/BUTTON RIGHT.png', self,
                              self.set_pos_right)
        right_button.setHasHighlight('../res/BUTTON RIGHT HIGHLIGHTED.png')

        self.add(back_button, z=1)
        self.add(left_button, z=1)
        self.add(right_button, z=1)
        self.add(self.lives, z=1)
        self.scroller.add(self.MGLayer, z=0)
        self.add(self.scroller, z=0)

        # initial view position
        self.scroller.set_focus(*self.pos)
예제 #6
0
class MainGame(cocos.scene.Scene):

    # init
    def __init__(self, director, state):

        self.director = director
        self.state = state

        self.dna = GameBackground('../res/main_game_backgrounds/main.png')
        # self.bg = GameBackground('../res/main_game_backgrounds/background.png')

        super().__init__()

        self.save_dir = 'profiles/save.json'
        if self.state == 'newgame':
            self.profile = Profile()
        else:
            self.profile = Profile() if not os.path.exists(
                self.save_dir) else Profile.read_save(self.save_dir)

        self.popups = {}
        self.shown_popup = None
        # for name in os.
        self.popups['finish_helicase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_helicase.png'),
            position=(640, 360))
        self.popups['fail_helicase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_helicase.png'),
            position=(640, 360))
        self.popups['finish_pp'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_pp.png'),
            position=(640, 360))
        self.popups['fail_pp'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_pp.png'),
            position=(640, 360))
        self.popups['finish_ligase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/finish_ligase.png'),
            position=(640, 360))
        self.popups['fail_ligase'] = cocos.sprite.Sprite(
            pyglet.image.load('../res/popups/fail_ligase.png'),
            position=(640, 360))

        for pop in self.popups.values():
            self.add(pop, 4)
            pop.do(Hide())

        self.case = self.profile.information['case']

        self.pos = [600, 0]

        self.life_num = self.profile.get_lives()
        print('new life number', self.life_num)
        self.lives = cocos.sprite.Sprite(
            pyglet.image.load('../res/lives_' + str(self.life_num) + '.png'),
            position=(224, 637))

        self.scroller = cocos.layer.ScrollingManager()
        self.MGLayer = MainGameLayer(self.director, self.scroller, self,
                                     self.case, self.profile, self.dna)

        back_button = Button(1199, 658, '../res/back_button.png', self,
                             self.back)
        back_button.setHasHighlight('../res/back_button_h.png')

        left_button = Button(1050, 90, '../res/BUTTON LEFT.png', self,
                             self.set_pos_left)
        left_button.setHasHighlight('../res/BUTTON LEFT HIGHLIGHTED.png')
        right_button = Button(1190, 90, '../res/BUTTON RIGHT.png', self,
                              self.set_pos_right)
        right_button.setHasHighlight('../res/BUTTON RIGHT HIGHLIGHTED.png')

        self.add(back_button, z=1)
        self.add(left_button, z=1)
        self.add(right_button, z=1)
        self.add(self.lives, z=1)
        self.scroller.add(self.MGLayer, z=0)
        self.add(self.scroller, z=0)

        # initial view position
        self.scroller.set_focus(*self.pos)

# setters/getters

# methods

    def on_enter(self):
        super(cocos.scene.Scene, self).on_enter()
        # super.on_enter()
        self.profile.save(self.save_dir)
        self.MGLayer.ch_layer.hide()
        print(self.MGLayer.ch_layer.__class__.is_event_handler)

    def main_next(self):

        if self.check_probs():
            self.profile.information['case'] += 1
            self.case += 1
            self.fix_probs()
        self.profile.save(self.save_dir)
        self.profile = Profile() if not os.path.exists(
            self.save_dir) else Profile.read_save(self.save_dir)

        # if self.case == 8:
        # cutscene = Cutscene(self.director, 2)
        # self.director.replace(cutscene)
        # else:
        # if victory:
        self.remove(self.MGLayer.ch_layer)
        self.scroller.remove(self.MGLayer)
        # instantiate new Main Game Layer
        self.MGLayer = MainGameLayer(self.director, self.scroller, self,
                                     self.case, self.profile, self.dna)
        self.scroller.add(self.MGLayer, z=1)
        self.director.pop()

    def check_probs(self):  # checks if all probs are done

        for i in self.profile.information['problems']:
            if i == False:
                return False
        return True

    def show_popup(self, popup_name):
        self.popups[popup_name].do(Show())
        self.shown_popup = popup_name

    def hide_popup(self):
        self.popups[self.shown_popup].do(Hide())
        self.shown_popup = None
        if self.case == 8:
            cutscene = Cutscene(self.director, 2)
            self.director.replace(cutscene)

    def fix_probs(self):  # checks if case has 2 probs
        if self.case in [2, 4, 6, 7]:
            self.profile.information['problems'] = [False, False]
        else:
            self.profile.information['problems'] = [False]

    def failed_minigame(self):
        self.subtract_life()
        self.profile.subtract_lives()
        # self.profile.save(self.save_dir)
        print(self.profile)
        self.back()

    def subtract_life(self):
        if self.life_num > 1:
            self.life_num -= 1
            print(self.life_num)
            self.lives.image = pyglet.image.load('../res/lives_' +
                                                 str(self.life_num) + '.png')
        else:
            self.back()
            print('failed game')

    def back(self):
        self.director.pop()
        print("select stage back")

    def set_pos_right(self):
        th.start_new_thread(self.pos_right, ())

    def set_pos_left(self):
        th.start_new_thread(self.pos_left, ())

    def pos_right(self):
        if self.pos[0] < 854:
            while self.pos[0] < 854:
                time.sleep(0.025)
                self.pos_op('add')
                self.scroller.set_focus(*self.pos)
        elif self.pos[0] >= 854:
            while self.pos[0] < 1067:
                time.sleep(0.025)
                self.pos_op('add')
                self.scroller.set_focus(*self.pos)
        return

    def pos_left(self):
        if self.pos[0] > 854:
            while self.pos[0] > 854:
                time.sleep(0.025)
                self.pos_op('min')
                self.scroller.set_focus(*self.pos)
        elif self.pos[0] <= 854:
            while self.pos[0] > 640:
                time.sleep(0.025)
                self.pos_op('min')
                self.scroller.set_focus(*self.pos)
        return

    def pos_op(self, op):
        if op == 'add':
            self.pos[0] = self.pos[0] + 16 / 2
        else:
            self.pos[0] = self.pos[0] - 16 / 2
def _recoverPreviousState():
    global previousStateFilename
    if previousStateFilename:
        profile = Profile.fromFile(previousStateFilename)
        profile.apply()
        previousStateFilename = None
def applyProfile(profileFile):
    profile = Profile.fromFile(os.path.join(os.path.dirname(__file__), 'userprofiles', profileFile))
    profile.apply()
    return profile
예제 #9
0
from PyQt4.QtCore import QSettings
from PyQt4.QtGui import QMessageBox

from qgis.core import QgsApplication
from qgis.utils import iface

from profiles.profile import Profile
from profiles.utils import saveCurrentStatus
import time

profiles = {}

profileFiles = glob.glob(os.path.join(os.path.dirname(__file__), '*.json'))
for f in profileFiles:
    profile = Profile.fromFile(f)
    profiles[profile.name] = profile


def customProfileFiles():
    customProfileFilepath = os.path.join(QgsApplication.qgisSettingsDirPath(), 'profiles')

    if os.path.exists(customProfileFilepath):
        return glob.glob(os.path.join(customProfileFilepath, '*.json'))
    else:
        return []


def hasCustomProfiles():
    return bool(customProfileFiles())
예제 #10
0
def _recoverPreviousState():
    global previousStateFilename
    if previousStateFilename:
        profile = Profile.fromFile(previousStateFilename)
        profile.apply()
        previousStateFilename = None
예제 #11
0
def applyProfile(profileFile):
    profile = Profile.fromFile(os.path.join(os.path.dirname(__file__), 'userprofiles', profileFile))
    profile.apply()
    return profile
예제 #12
0
import time

from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QMessageBox

from qgis.core import QgsApplication
from qgis.utils import iface

from profiles.profile import Profile
from profiles.utils import saveCurrentStatus

profiles = {}

profileFiles = glob.glob(os.path.join(os.path.dirname(__file__), '*.json'))
for f in profileFiles:
    profile = Profile.fromFile(f)
    profiles[profile.name] = profile


def customProfileFiles():
    customProfileFilepath = os.path.join(QgsApplication.qgisSettingsDirPath(),
                                         'profiles')

    if os.path.exists(customProfileFilepath):
        return glob.glob(os.path.join(customProfileFilepath, '*.json'))
    else:
        return []


def hasCustomProfiles():
    return bool(customProfileFiles())