【问题标题】:What would be a better way to program a chest and key system?对胸部和钥匙系统进行编程的更好方法是什么?
【发布时间】:2022-06-14 18:42:36
【问题描述】:

这是“钥匙”功能

def Key(playPos1,playPos2,Key1,Key2):
  if turn ==1:
    if playPos1 == 9 or playPos1 == 21:
     Key1 = 1
  else:
    if turn ==2:
      if playPos2 == 9 or playPos2 == 21:
       Key2 = 1
  return playPos1,playPos2,Key1,Key2

这就是“胸部”功能

def Chest(playPos1,playPos2,playerG,Key1,Key2): 
    if playPos1 == 10  and Key1 ==1:
      playerG = playerG + 500
      Key1 = 0
    elif playPos1 == 23 and Key1 == 1:
      playerG = playerG + 200
      Key1 = 0
    elif playPos1 == 26 and Key1 == 1:
      playerG = playerG + 400
      Key1 = 0
    elif playPos2 == 10  and Key2 ==1:
      playerG = playerG + 500
      Key2 = 0
    elif playPos2 == 23 and Key2 == 1:
      playerG = playerG + 200
      Key2 = 0
    else:
      if playPos2 == 26 and Key2 == 1:
        playerG = playerG + 400
        Key2 = 0
    return playPos1,playPos2,playerG,Key1,Key2

我的问题是每当我运行“胸部功能它不起作用”

def tileNumber10(playPos1,playPos2,playerG,turn,playerImmunity1,playerImmunity2,playerMultiply1,playerMultiply2,Key1,Key2): 
  if turn == 1:
    playPos1 = 10
    playerG = Chest(playPos1,playPos2,playerG,Key1,Key2)
    print("You now have",playerG,"and on tile number",playPos1)
  elif turn ==2:
    playPos2 = 10
    playerG = Chest(playPos1,playPos2,playerG,Key1,Key2)
    print("You now have",playerG,"and your on tile number",playPos2)
  return playPos1,playPos2,playerG,turn,playerImmunity1,playerImmunity2, playerMultiply1,playerMultiply2

我知道我必须使用类,但 atm 我不能真正使用它,所以有人可以帮助我 idk if this image helps with anything

【问题讨论】:

  • 你能比“它不起作用”更具体吗
  • 欢迎来到 StackOverflow,请查看如何ask a good question。目前,您绝对没有提供 minimal 示例,而且您的问题描述(“它不起作用”)含糊不清,令人无法接受。

标签: python


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-25
  • 1970-01-01
  • 1970-01-01
  • 2011-07-21
  • 1970-01-01
相关资源
最近更新 更多