コード例 #1
0
f = Functions()
u = User()
l = Log()
e = Employees()
n = Notification()
preq = PurchaseRequest()
pord = PurchaseOrder()
reqQ = RequestForQuotation()
abc = AbstractOfCanvass()
supp = Suppliers()
prop = PropertyAcceptanceReceipt()
kp = KeyPositions()
insp = InsepectionAndAcceptanceReceipt_2()
itemClass = Items()
supplyClass = Supply()
offClass = Offices()
risClass = RequisitionAndIssuanceSlip()
off = Offices()
taskClass = Tasks()

#dirreq = dirname(dirname(abspath(__file__)))
#sys.path.append('{}\SuperUser\static\src'.format(dirreq))

from SuperUser.forms import PhotoForm
from SuperUser.models import Photo


def index(request):

    loopRef = genLoopRangeString(5, [('rr', 'tt', 'yy', 'uu'),
コード例 #2
0
l = Log()
e = Employees()
n = Notification()
ins = InsepectionAndAcceptanceReceipt()
pOrd = PurchaseOrder()
preq = PurchaseRequest()
propAR = PropertyAcceptanceReceipt()
reqQ = RequestForQuotation()
pord = PurchaseOrder()
off = Offices()
kp = KeyPositions()
suppl = Suppliers()
itemC = Items()
equip = Equipment()
ris_Class = RequisitionAndIssuanceSlip()
supplyC = Supply()
waste_Class = Waste()
abc = AbstractOfCanvass()

templateFolder = 'inventory_office'
urlHead = '/inventory_office_inv_clerk'

def index(request):
    return setReponse(request, templateFolder+'/home_new_again.html', [], [], [], [], [('inventory_office/base.html',),])

def search(request):


    theCookieValue = getSessionData(request, 'theCookie')
    logDetails = l.getLogDetails(theCookieValue)
コード例 #3
0
ファイル: supplier.py プロジェクト: yachtless/h3_homework
 def add_supply(self, item, amount):
     new_supply = Supply(item, self, amount)
     self.supply.append(new_supply)
     return new_supply
コード例 #4
0
 def setUp(self) -> None:
     self.config = GameConfig(num_players=2, sandbox=False)
     self.supply = Supply(self.config)
コード例 #5
0
ファイル: supplier.py プロジェクト: nastinasti/h3_homework
 def add_supply(self, item, amount):
     new_supply = Supply(item, self, amount)
     self.supply.append(new_supply)
     logger.debug(f"Supplier {new_supply} is added")
     return new_supply
コード例 #6
0
ファイル: main.py プロジェクト: bantu4me/play_plane
def main():
    # 播放背景音乐
    pygame.mixer.music.play(-1)
    # 创建我的飞机
    me = MyPlane(bg_size)
    # 动画切换标记
    switch_img = True
    # 延迟刷新控制
    delay = 5
    # 初始化敌机
    enemies = pygame.sprite.Group()
    add_enemies(enemies, 15)
    # 初始化中型敌机
    add_enemies(enemies, 10, type=2)
    # 初始化大型敌机
    add_enemies(enemies, 10, type=3)
    # 初始化子弹
    bullet_index = 0
    bullet_num = 4
    bullets = add_bullets(bullet_num, me.rect.midtop)
    # 初始化双倍子弹 左右弹道
    bullets_left = add_bullets(bullet_num, me.rect.midtop, type=2, deviation=1)
    bullets_right = add_bullets(bullet_num,
                                me.rect.midtop,
                                type=2,
                                deviation=2)
    running = True
    # 绘制分数信息
    font = pygame.font.SysFont('', 35)
    score = 0
    score_info = 'Score='

    # 补给
    supply = Supply(bg_size)
    bomb_num = 0

    # 双倍子弹
    double_bullets_flag = False
    # 双倍子弹时间限制
    double_bullets_start = 0
    double_bullets_limit = 5

    while running:
        # 事件循环检测
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            # 检测按下了空格键,炸毁视野中的飞机
            space_down = pygame.key.get_pressed()
            if space_down[K_SPACE] and bomb_num > 0:
                bomb_num -= 1
                vis = 0
                for e in enemies:
                    if e.visible:
                        vis += 1
                        e.active = False

        key = pygame.key.get_pressed()
        # 方向操作
        if key[K_UP]:
            me.moveUp()
        if key[K_DOWN]:
            me.moveDown()
        if key[K_LEFT]:
            me.moveLeft()
        if key[K_RIGHT]:
            me.moveRight()

        # 控制飞机每五秒钟切换一次动画
        delay -= 1
        if not delay:
            delay = 100
        if not (delay % 5):
            switch_img = not switch_img
            me.active_flag = switch_img
        # 绘制背景
        screen.blit(background, origin)

        # 绘制我的飞机
        # 增加碰撞检测
        me_enemies_hit = pygame.sprite.spritecollide(
            me, enemies, False, pygame.sprite.collide_mask)
        if me_enemies_hit:
            me.active = False
            for e in me_enemies_hit:
                e.active = False
        if me.active:
            screen.blit(me.active_img, me.rect)
        else:
            me_down_sound.play()
            if not (delay % 3):
                screen.blit(me.destory_imgs[me.destory_index], me.rect)
                me.destory_index += 1
                if me.destory_index == len(me.destory_imgs):
                    me.destory_index = 0
                    me.active = True

        # 绘制敌机
        for e in enemies:
            if e.active:
                e.move()
                # 判断飞机类型绘画血条
                if e.type != 1:
                    draw_hp(screen, e)
                screen.blit(e.image, e.rect)
            else:
                if not (delay % 3):
                    if e.destory_index == 0:
                        enemy1_down_sound.play()
                    screen.blit(e.destory_imgs[e.destory_index], e.rect)
                    e.destory_index += 1
                    if e.destory_index == len(e.destory_imgs):
                        e.reset()
                        score += e.score

        if not double_bullets_flag:

            # 子弹重绘
            if not (delay % 10) and len(bullets) > 0:
                bullets[bullet_index].reset(me.rect.midtop)
                bullet_index = (bullet_index + 1) % bullet_num

            # 子弹
            for b in bullets:
                if b.active:
                    b.move()
                    screen.blit(b.image, b.rect)
                    enemies_hit = pygame.sprite.spritecollide(
                        b, enemies, False, pygame.sprite.collide_mask)
                    if enemies_hit:
                        # 子弹击中目标重置位置
                        b.reset(me.rect.midtop)
                        for e in enemies_hit:
                            # 击落敌机
                            if e.type == 1:
                                e.active = False
                            elif e.type == 2 or e.type == 3:
                                if e.hp > 0:
                                    e.hp -= 1
                                    e.is_hit = True
                                else:
                                    e.active = False
        else:
            # 子弹重绘
            if not (delay % 10):
                bullets_left[bullet_index].reset(me.rect.midtop)
                bullets_right[bullet_index].reset(me.rect.midtop)
                bullet_index = (bullet_index + 1) % bullet_num

            # 子弹
            for b, j in zip(bullets_left, bullets_right):
                if b.active:
                    b.move()
                    screen.blit(b.image, b.rect)
                    enemies_hit = pygame.sprite.spritecollide(
                        b, enemies, False, pygame.sprite.collide_mask)
                    if enemies_hit:
                        # 子弹击中目标重置位置
                        b.reset(me.rect.midtop)
                        for e in enemies_hit:
                            # 击落敌机
                            if e.type == 1:
                                e.active = False
                            elif e.type == 2 or e.type == 3:
                                if e.hp > 0:
                                    e.hp -= 1
                                    e.is_hit = True
                                else:
                                    e.active = False
                if j.active:
                    j.move()
                    screen.blit(j.image, j.rect)
                    enemies_hit = pygame.sprite.spritecollide(
                        j, enemies, False, pygame.sprite.collide_mask)
                    if enemies_hit:
                        # 子弹击中目标重置位置
                        j.reset(me.rect.midtop)
                        for e in enemies_hit:
                            # 击落敌机
                            if e.type == 1:
                                e.active = False
                            elif e.type == 2 or e.type == 3:
                                if e.hp > 0:
                                    e.hp -= 1
                                    e.is_hit = True
                                else:
                                    e.active = False

        # 提供补给的粗略逻辑:
        # 每30秒钟以30%的概率出现一个补给
        if supply.active:
            supply.move()
            screen.blit(supply.image, supply.rect)
        else:
            supply.re_init()

        supply_get = pygame.sprite.collide_mask(me, supply)

        if supply_get:
            supply.active = False
            if supply.supply_type == 0:
                double_bullets_flag = True
                double_bullets_start = time.time()
                print(double_bullets_start)
                # 重置子弹的位置
                for b_l, b_r in zip(bullets_left, bullets_right):
                    b_l.reset(me.rect.midtop)
                    b_r.reset(me.rect.midtop)

            elif supply.supply_type == 1:
                if bomb_num < 3:
                    bomb_num += 1

        if double_bullets_flag:
            double_bullets_end = time.time()
            # 超过30秒后取消双倍子弹
            t = double_bullets_end - double_bullets_start
            # print('t:',t)
            if t > double_bullets_limit:
                double_bullets_flag = False
                for b in bullets:
                    b.reset(me.rect.midtop)

        draw_bomb(screen, bomb_num)

        score_sur = font.render(score_info + str(score), True, BLACK)
        screen.blit(score_sur, (10, 10))

        pygame.display.flip()
        # 设置一个帧数刷新率,没看懂这里的原理,官网文档设置了40,测试40有卡顿感觉
        clock.tick_busy_loop(60)
コード例 #7
0
ファイル: system.py プロジェクト: JimmyZhang12/predict-T
  plt.legend()
  plt.show()
  #plt.savefig(outfile+"period_"+str(i)+".png")

imax = 5
imin = 0.1
vmin = 1.05
vmax = 1.2
rpdn = 0.2e-3
rll = (vmax - vmin)/imax

duty_cycles = list(np.linspace(0.10, 0.90, 10))
amplitudes = list(np.linspace(imin, imax-imin, 10))
cpu = [[CPU(10e-6, i, 100, j, imin) for i in duty_cycles] for j in amplitudes]
ll = list(np.linspace(10e-6, 0.8*rll, 6))
supplies = [Supply(rpdn, i, vmax, vmin, imax, 0) for i in ll]

energies = np.zeros((len(amplitudes), len(duty_cycles), len(ll)))
energies_o = np.zeros((len(amplitudes), len(duty_cycles)))
savings = np.zeros((len(amplitudes), len(duty_cycles), len(ll)))

supply_base = Supply(rpdn, rll, vmax, vmin, imax, 0)

time = 0
tick = 0
timestep = 1e-9
energy_originals = 0
duration=20e-6
while time < duration:
  for i in range(len(amplitudes)):
    for j in range(len(duty_cycles)):
コード例 #8
0
ファイル: supplier.py プロジェクト: diachkina/h3_homework
 def add_supply(self, item, amount):
     new_supply = Supply(item, self, amount)
     self.supply.append(new_supply)
     self.log.info(f'Supplier added supply {self.supply}')
     return new_supply