1 from experience_table
import *
2 import utility
, math
, craw
, packets
, configuration
4 class experience_handler_class
:
5 def process_bytes(self
, bytes
):
11 self
.experience
= craw
.get_experience()
12 if self
.experience
== None:
15 elif len(bytes
) >= 5 and bytes
[0] == 0x1c:
16 new_experience
= utility
.read_bytes(bytes
, 1, 4)
17 self
.process_experience(new_experience
- self
.experience
)
20 for identifier
, size
in experience_formats
:
21 if len(bytes
) >= 1 + size
and bytes
[0] == identifier
:
22 experience_gained
= utility
.read_bytes(bytes
, 1, size
)
23 self
.process_experience(experience_gained
)
26 def process_experience(self
, experience_gained
):
27 player
= utility
.get_my_player()
31 experience_for_this_level
= experience_table
[player
.level
- 1]
32 experience_for_next_level
= experience_table
[player
.level
]
33 current_experience
= self
.experience
34 remaining_experience
= experience_for_next_level
- current_experience
35 kills_required
= int(math
.ceil(float(remaining_experience
) / experience_gained
))
36 experience_difference
= current_experience
- experience_for_this_level
37 experience_in_this_level
= experience_for_next_level
- experience_for_this_level
38 progress
= float(experience_difference
) / experience_in_this_level
* 100.0
39 self
.experience
+= experience_gained
40 if kills_required
> configuration
.experience_peanut_limit
:
42 print 'Gained %d experience points, kill %d more of these (%.2f%%)' % (experience_gained
, kills_required
, progress
)