Skip to content

Commit

Permalink
fix mutations overriding spell level
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Sep 22, 2019
1 parent 178117c commit bfe7480
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/magic.cpp
Expand Up @@ -730,6 +730,11 @@ void spell::gain_exp( int nxp )
experience += nxp;
}

void spell::set_exp( int nxp )
{
experience = nxp;
}

std::string spell::energy_string() const
{
switch( type->energy_source ) {
Expand Down Expand Up @@ -1117,7 +1122,11 @@ void known_magic::deserialize( JsonIn &jsin )
std::string id = jo.get_string( "id" );
spell_id sp = spell_id( id );
int xp = jo.get_int( "xp" );
spellbook.emplace( sp, spell( sp, xp ) );
if( knows_spell( sp ) ) {
spellbook[sp].set_exp( xp );
} else {
spellbook.emplace( sp, spell( sp, xp ) );
}
}
}

Expand Down Expand Up @@ -1152,6 +1161,10 @@ void known_magic::learn_spell( const spell_type *sp, player &p, bool force )
debugmsg( "Tried to learn invalid spell" );
return;
}
if( p.magic.knows_spell( sp->id ) ) {
// you already know the spell
return;
}
spell temp_spell( sp->id );
if( !temp_spell.is_valid() ) {
debugmsg( "Tried to learn invalid spell" );
Expand Down
1 change: 1 addition & 0 deletions src/magic.h
Expand Up @@ -284,6 +284,7 @@ class spell
int xp() const;
// gain some exp
void gain_exp( int nxp );
void set_exp( int nxp );
// how much xp you get if you successfully cast the spell
int casting_exp( const player &p ) const;
// modifier for gaining exp
Expand Down

0 comments on commit bfe7480

Please sign in to comment.