[hamster-applet] the "all wrong" trophy
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] the "all wrong" trophy
- Date: Wed, 18 Aug 2010 00:53:23 +0000 (UTC)
commit abb3f09da71be6cd50da4f45a68bfdb07159592d
Author: Toms Bauģis <toms baugis gmail com>
Date: Wed Aug 18 01:47:28 2010 +0100
the "all wrong" trophy
src/hamster/client.py | 11 ++++++++---
src/hamster/trophies.py | 15 +++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/src/hamster/client.py b/src/hamster/client.py
index 7870a5a..413012b 100644
--- a/src/hamster/client.py
+++ b/src/hamster/client.py
@@ -229,9 +229,14 @@ class Storage(gobject.GObject):
tags = ", ".join(tags)
tags = tags or ''
- return self.conn.UpdateFact(fact_id, activity_name, tags,
- start_time, end_time,
- category_name, description, temporary)
+ new_id = self.conn.UpdateFact(fact_id, activity_name, tags,
+ start_time, end_time,
+ category_name, description, temporary)
+
+ checker.check_update_based(fact_id, new_id, activity_name, tags,
+ start_time, end_time,
+ category_name, description)
+ return new_id
def get_category_activities(self, category_id = None):
diff --git a/src/hamster/trophies.py b/src/hamster/trophies.py
index d408eef..d05878a 100644
--- a/src/hamster/trophies.py
+++ b/src/hamster/trophies.py
@@ -37,6 +37,21 @@ class Checker(object):
if trophies_client:
self.trophies = trophies_client.Storage()
+ # some state flags
+ self.last_update_id = None
+
+
+ def check_update_based(self, prev_id, new_id, activity_name, tags, start_time, end_time, category_name, description):
+ if not self.last_update_id or prev_id != self.last_update_id:
+ self.same_updates_in_row = 0
+ elif self.last_update_id == prev_id:
+ self.same_updates_in_row +=1
+ self.last_update_id = new_id
+
+
+ # all wrong â?? edited same activity 5 times in a row
+ if self.same_updates_in_row == 5:
+ self.trophies.unlock_achievement("hamster-applet", "all_wrong")
def check_fact_based(self, activity_name, tags, start_time, end_time, category_name, description):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]