Now popping objects too.
This commit is contained in:
		
					parent
					
						
							
								fd230e87e9
							
						
					
				
			
			
				commit
				
					
						9d5971e23a
					
				
			
		
					 2 changed files with 47 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -66,7 +66,13 @@ namespace character {
 | 
			
		|||
 | 
			
		||||
        void push_object(const billyObject &object, CharacterSheet &sheet) noexcept;
 | 
			
		||||
 | 
			
		||||
        void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
 | 
			
		||||
        void pop_object(CharacterSheet &sheet) noexcept;
 | 
			
		||||
 | 
			
		||||
        [[nodiscard]] std::pair<const container &, std::int8_t> get_objects() const noexcept {
 | 
			
		||||
            return { objects, end_object };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
//        void insert_weapon(weapons weapon, CharacterSheet &sheet) noexcept;
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        container objects;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,6 +48,46 @@ namespace character {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void BillyObjects::pop_object(CharacterSheet &sheet) noexcept {
 | 
			
		||||
        if (end_object > 0) {
 | 
			
		||||
            const auto &obj = objects.at(end_object - 1);
 | 
			
		||||
            --end_object;
 | 
			
		||||
 | 
			
		||||
            auto &local_habilete = static_cast<Characteristic &>(sheet.habilete);
 | 
			
		||||
            auto &local_adresse = static_cast<Characteristic &>(sheet.adresse);
 | 
			
		||||
            auto &local_endurance = static_cast<Characteristic &>(sheet.endurance);
 | 
			
		||||
            auto &local_chance = static_cast<Characteristic &>(sheet.chance);
 | 
			
		||||
 | 
			
		||||
            std::visit(overloaded{
 | 
			
		||||
                    [&](const weapons &arg) {
 | 
			
		||||
                        --sheet.nb_weapons;
 | 
			
		||||
                        change_carac_weapon(arg, sheet, local_habilete, local_adresse, local_endurance, minus);
 | 
			
		||||
                    },
 | 
			
		||||
                    [&](const equipments &arg) {
 | 
			
		||||
                        --sheet.nb_equipments;
 | 
			
		||||
                        change_carac_equipment(arg,
 | 
			
		||||
                                               sheet,
 | 
			
		||||
                                               local_habilete,
 | 
			
		||||
                                               local_adresse,
 | 
			
		||||
                                               local_endurance,
 | 
			
		||||
                                               local_chance,
 | 
			
		||||
                                               minus,
 | 
			
		||||
                                               plus);
 | 
			
		||||
                    },
 | 
			
		||||
                    [&](const tools &arg) {
 | 
			
		||||
                        --sheet.nb_tools;
 | 
			
		||||
                        change_carac_tools(arg,
 | 
			
		||||
                                           sheet,
 | 
			
		||||
                                           local_habilete,
 | 
			
		||||
                                           local_adresse,
 | 
			
		||||
                                           local_endurance,
 | 
			
		||||
                                           local_chance,
 | 
			
		||||
                                           minus);
 | 
			
		||||
                    }
 | 
			
		||||
            }, obj);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void BillyObjects::change_carac_tools(const tools &arg,
 | 
			
		||||
                                          CharacterSheet &sheet,
 | 
			
		||||
                                          Characteristic &localHabilete,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue