Skip to content

Commit

Permalink
Have announcements be announced through Nuwani
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLVP committed Jun 11, 2020
1 parent b28ff12 commit d20d535
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions data/irc_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"notice-report": "<prefix:%><color:2>*** <color:7>Report from %s (Id:%d) about %s (Id:%d):<color> %s",
"notice-say": "<color:10>*** Message from %s: %s",

"achievement": "<color:12>*** %s (Id:%d) has earned the achievement %s. Congratulations!",

"status": "<color:2>[%d] <color:7>%s %s",

"report": "<target:#LVP.Crew><color:7>Report from <color:5>%s <color:7>(Id:%d) about <color:5>%s <color:7>(Id:%d):<color> %s",
Expand Down
7 changes: 6 additions & 1 deletion javascript/features/collectables/achievements.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ export const kAchievements = new Map([
// Implements tracking and collecting of achievements for each of the players. They cannot be drawn
// on the map, but fit in with other collectables reasonably well otherwise.
export class Achievements extends CollectableBase {
collectables_ = null;
manager_ = null;
nuwani_ = null;

constructor(collectables, manager) {
constructor(collectables, manager, nuwani) {
super({ name: 'Achievements' });

this.collectables_ = collectables;
this.manager_ = manager;
this.nuwani_ = nuwani;
}

// ---------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -180,6 +183,8 @@ export class Achievements extends CollectableBase {

recipient.sendMessage(formattedMessage);
}

this.nuwani_().echo('achievement', player.name, player.id, name);
}

// ---------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions javascript/features/collectables/collectable_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CollectableManager {
delegates_ = null;
notifications_ = new WeakMap();

constructor(collectables, settings) {
constructor(collectables, nuwani, settings) {
this.collectables_ = collectables;
this.settings_ = settings;
this.settings_.addReloadObserver(
Expand All @@ -39,7 +39,7 @@ export class CollectableManager {
this.delegates_ = new Map([
[ CollectableDatabase.kRedBarrel, new RedBarrels(collectables, this) ],
[ CollectableDatabase.kSprayTag, new SprayTags(collectables, this) ],
[ CollectableDatabase.kAchievement, new Achievements(collectables, this) ],
[ CollectableDatabase.kAchievement, new Achievements(collectables, this, nuwani) ],
]);

server.playerManager.addObserver(this, /* replayHistory= */ true);
Expand Down
5 changes: 4 additions & 1 deletion javascript/features/collectables/collectables.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ export default class Collectables extends Feature {
// Allows us to take money from the player for collectable location hints.
const finance = this.defineDependency('finance');

// Achievements should be announced to people watching through Nuwani as well.
const nuwani = this.defineDependency('nuwani');

// Certain behaviour of the Collectables feature is configurable as settings.
const settings = this.defineDependency('settings');

// The manager is responsible for keeping track which collectables have been collected by
// which players, and enables creation of new "rounds" of collectables.
this.manager_ = new CollectableManager(this, settings);
this.manager_ = new CollectableManager(this, nuwani, settings);

// The commands are the player's interfaces towards being able to control their collectables
// and achievements, as well as seeing other player's statistics.
Expand Down
2 changes: 1 addition & 1 deletion pawn/config.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
class Version {
public const Major = 47;
public const Minor = 0;
public const Minor = 4;
};

// Set this to 1 if you'd like to build Las Venturas Playground in release mode. This affects
Expand Down

0 comments on commit d20d535

Please sign in to comment.