Hi guys. I have a... small... problem with conditionals. My roguelike based on Jotaf's tutorial, but during one and a half years working on it I learnt a lot about Python (but I'm still a novice, my profession is the totally unrelated to programming). Roguelike has wilderness, cities (above-ground and underground), classes, races, d20srd system, etc. Now I'm working on quests... And here there is problem.
I have three lists (are made in the same manner): active_quest, past_quest, quest_item_inventory. Start with empty lists; when you talk to specific NPC game add 'firstquest' to active_quest list. When 'firstquest' is in active_quest, new location in worldmap appear. PC descends on the third level of location, take 'firstquestitem'. 'firstquestitem' is added to the list quest_items_inventory. All the aforesaid works, I tested it.
Problem occurs with interaction with the NPC at the completion of the quest. Action should be such as:
talk
if you are talking with first_npc_from_first_city:
if 'firstquest' is inactive and isn't in past_quest
add 'firstquest' to active_quest
npc say 'give me firstquestitem'
if 'firstquest' is active and player have not 'firstquestitem'
npc say 'found firstquestitem'
if 'firstquest' is active and player have 'firstquestitem'
remove 'firstquestitem' from quest_item_inventory
remove 'firstquest' from active_quest
add 'firstquest' to past_quest
npc say 'thx'
if 'firstquest' is inactive and is in past_quest
npc say 'you are true hero!'
code looks like this (with some changes, I have tried several, hm, solutions (?))
if '1st npc 1st city' in object.name: #NPC named '1st...'
if 'firstquest' not in active_quest and 'firstquest' not in past_quest:
message('add 1st_q_from_1st_c to active_quest!')
active_quest.append('firstquest')
return
elif 'firstquest' in active_quest:
if 'firstquestitem' in quest_items_inventory: #PC have questitem
message('thx')
quest_items_inventory.remove('firstquestitem')
active_quest.remove('firstquest')
past_quest.append('firstquest') #end of quest
return
else:
message('where is firstquestitem?') #PC have not firstquestitem
elif 'firstquest' in past_quest:
message('you are true hero') #talk after complete quest
return
else:
message('error?') #test
I made some tests. I'm sure that 'firstquestitem' is in quest_items_inventory. It seems that python cannot read the content of quest_item_inventory. It surprise me, because there are no such problems with active_quest which is constructed in a same manner.
Can someone tell me what could cause this?