Super Bodyguard (2016) – Review

Mandarin with English subtitles
Directed, written and produced by Yue Song
Starring: Yue Song, Xing Yu, Collin Chou, Michael Chan
Link: IMDB
Link: Trailer – Youtube

“An insane, rip-roaring, ultra-fast old-school Hong Kong action film that hides flaws in editing, poor continuity, storyline and character development.

In this heddy mix of “comic-book” superhero action, streetfighting, drama and mindless fun; Yue Song stars as Wu-Lin, a “Super bodyguard” assigned to be the bodyguard of an unruly, unappreciative daughter of one of the richest families in the city; whilst fending off attacks from a group of mobsters.

Wu-lin’s “super bodyguard” status comes from his “Iron Feet”, a secret martial arts technique that forces him to wear heavy iron overshoes for 10 years; which allows him to kick ass; and hard.

In the shadows is Wu-lin’s brother; another martial artist and bodyguard business partner who is obsessed with the technique, and wants it all to himself; and is willing to go to any length to learn it.

The brother; drunk with desire to learn the skill even joining forces with the mobsters to eventually kidnap the girl, and brutally putting Wu-lin into a shallow grave when he refuses to have anything to do with him.

Wu-Lin’s rises from the graves, takes off his iron-shoes, and decides to wipe out the gangsters once and for all and save the daughter from any further harm.

In a movie that Yue Song himself said, “The best [kung fu] film you’ll never see” (link), “Super Bodyguard” manages to channel the best of old-school Hong Kong action movies, combining it into a heady mixture that combines evil kung-fu clans, comic-book action, hundreds of bad guys into relentless action.

It’s clear that director, and star, Yue Song loves his action; fists, feet fly across the screen at reckless speed, almost to the point you dare not blink or you’ll miss something.

It’s no small feat either; as Yue Song was the director, writing, producing and heck; throw in stunt co-ordination as well on this movie.

With his strong background in martial arts, Yue throws himself into a plot that mostly serves as a thinly veiled vehicle to string together a lot of bone-shattering, fast-paced action sequences.

And yet, there were a lot of issues I had with the movie.

It really needed a seasoned producer at the helm.

Perhaps it was the English subtitles, but there were a lot of times where the storyline and key scenes just jump from one sequence to another. I found it very distracting.

There are also quite a few continuity issues with the movie too. Early on, a kid is teasing Yue Song with some ice cream as Song is doing the splits in an plaza (for some reason, its never explained what he’s doing there).

Suddenly a van of well dressed guys turn up, the camera is now pointing downwards — but wait, where did the little kid go to? Then, in the next shot the kid is back.

There are a number of key sequences that made me quite annoyed; they lead somewhere. Then there’s a cut and then it moves onto another scene.

An example of this is the chase between Song and a van of hoodlums who kidnap the daughter. The sequence runs for many minutes, with Yue chasing, jumping, riding the top; its all crazy stuff — but I kept asking myself how the slowly van must be travelling for Yue able to scale buildings and urban furniture and yet still keep up with a moving vehicle.

The whole sequence ends with Song IN-FRONT of the van, how the hell did he get there? It’s scenes like this and others similar to this that really made me scratch my head in confusion.

Another example; later on Song is faced with a guy with a sword and a bandage around his hand. Yue walks up to him, but before we can see anything — the camera cuts, and the next scene the sword-wielding victim is on the floor.

What was the point of that scene?

Another issue I had was that a lot of the background story is never explained until 30-50 minutes into the movie. I found this to be very poor and could have easily been the basis of the whole movie if they did it correctly.

There’s one quick scene where Wu-lin’s character is in his room and there are James Bond posters on the wall; I’m not sure why they are there. But it was interesting he had Pierce Brosnan’s GoldenEye and one of Dalton’s movies (Licence to Kill).

For a movie that touted itself as the next “Bruce Lee” in some promotions, and yet in another a movie that claims to have no special effects; the movie lends itself to using a lot — and I mean a lot of wire-fu.

Now, that wouldn’t be an issue if the story really laid out a solid foundation of why Yue Song’s character is able to perform superhero like bone-crunching moves.

The only real explanation we get is midway through the movie; that he was abandoned, had some kind of supernatural ability and was taught by an old man; before he too abandons Yue — telling him “success needs sacrifice”.

Even his “brother” isn’t really fleshed out; is he his real blood brother, step-brother (which is hinted at in the movie), his martial arts brother?

I do wish they had pushed the idea of him being a step brother a bit more to beefen up the story.

The storyline of this movie should have been “Success needs sacrifice”, and could have told the story of how the father adopts the abandoned Wu-lin (Yue Song) and quickly identifies his gift; and teaches him along side his blood-son; the story could have told it from the step-brother’s point of view about he secretly dispises his father for saving Wu Lin — and this would have helped fueled the blood feud between the two.

There are also parts of the movie that are very rushed. The “romance” between the bodyguard Wu-Lin and the daughter; almost immediately they fall in love. Although strangely Wu-lin never seems to act like he’s in love.

In this movie Song also has a tendency to “honour” wholesale sequences from movies he’s a fan of.

Whilst the most obvious one is “The Matrix Revolution”; where Song is battling a load of bad guys at the same time.

There are some other ones that I felt needed to be highlighted. Early on, Wu-lin is doing the splits in a plaza being taunted by a little kid who is eating ice cream. This is clearly similar to Bruce Lee’s “Way of the Dragon” where a similar sequence occurs.

Later on, the whole bit where Wu-lin is failing to “protect” the daughter from a group of street hoodlums is clearly lifted wholesale from Jackie Chan’s “Police Story” (1985). But weirdly Chan’s version is better, because its background story is well developed, and funnier. Whereas here, it just happens.

Aside from poor storyline development, poor character development and sequences that break continuity or just seemed very rushed — I thought the movie was very good, well paced and had a lot of action in it.

It’s a movie that tries to mix Tony Jaa like bone-crunching action with Chinese folklore wire-fu action of old.

But I felt there was a certain disconnect with the two ideas; and it isn’t helped with the lack of a decent story.

It’s brutal, fast-paced and worth watching. One hopes that Yue Song gets it into cinemas worldwide; if it does — I certainly will be there.

Overall: 7/10

Two apps published for app store

Recently I have written and published two iOS apps for the Apple App Store.

moa-icon

Merchants of Amsterdam Clock Utility App
A Universal iOS app replacement for the Dutch auction wind-up clock for the board game “Merchants of Amsterdam”.

The app requires version 8.1 or above. This is because some dependencies required this.

It is currently on the app store (link)

Further information can be obtained on the project page.

—-

Peak Solitaire Card Game app

peaks-icon

A solitaire card game. Uses Game Center Leaderboard to record your high scores.

This app requires version 8.1 or above.

It is on the app store (link)

Review – Jason Bourne (2016)

Jason Bourne

UK Rated 12A
Director: Paul Greengrass
Stars: Matt Damon, Tommy Lee Jones, Alicia Vikander

Review contains spoilers

Matt Damon returns as the elusive black ops operative Jason Bourne, in an action-packed, fast-paced summer movie that packs a punch, but isn’t as good as the prior movies or as good as it could have been.

Damon’s much anticipated reprisal of the Jason Bourne character has been long rumoured, despite Matt’s uneasiness to revisit the character.

For years, Damon has been talking about he didn’t want to return for a part he clearly no longer likes, in a production he would rather not be in.

After all, the character arc had been fulfilled in The Bourne Ultimatum (2007), there wasn’t anything else to bring. Further, Matt didn’t want to revisit the character without director Paul Greengrass at the helm.

Presumably, after a big money deal — both Greengrass and Damon are back on board; cinema goers can follow the continuing saga of Jason Bourne.

Living off the grid, and haunted by his own demons about his past; Bourne is drawn out of hiding to uncover hidden truths about his past, and to get revenge on those whom he blames for his situation.

Julia Stiles returns as Nicky Parson; a friend and former associate of Bourne, works with a hacker/whistle blower to expose the CIA black’s ops via a remote station in Iceland. This hack exposes Parson to the CIA, and they suspect that Parson is in league with Bourne, and fear that Jason will expose the CIA’s operations publicly.

Their tracking leads directly to Jason in the middle of a Greek Protest, used as a cover for the exchange of data between Parson and Bourne; however the CIA are hot on their tail.

Ordered by CIA director, Robert Dewey, the CIA hit squads track Jason throughout the Greek Protest; until Nicky is slain by a sniper, called “The Asset”.

The movie continues from there as a chase movie, with Jason chasing after the CIA black ops teams throughout the world; and the CIA director using “The Asset” to eliminate Jason once and for all.

Added into the mix is a social media platform (Facebook all but in name) and its dealings with the CIA director, and a constant theme of privacy runs throughout the movie; until the rip-roaring finale at a Tech convention in Texas; where The Asset and Jason Bourne match up in a car-chase finale.

There is a lot going on in Jason Bourne. The movie is a fast-past chase movie, things move at a fast pace; and I certainly enjoyed the experience.

However. Jason Bourne is the weakest of all the series.

It hasn’t got the class of the original, nor as the story as tight as “The Bourne Ultimatum” (2007); neither is at as effective as The Bourne Supremacy (2004). My won feeling is the Ultimatum is the best one, but the original had impact; it influenced a lot of movies, including the James Bond franchise.

Things I liked;

In this movie we have Jason Bourne knowing who he actually is, cured of amnesia, and battling an even larger enemy than before. There are car chases, well choreographed fight scenes,shootouts,explosions and everything else you would want from an action movie. This is something I enjoyed.

I really liked the whole 2 or 3 false flag sub-plots, we find out Bourne’s own inclusion in the CIA black ops program was a false flag, and CIA Director is plotting to use a false flag to undermine the social media and stronger privacy.

I loved all scenes involving crowds in this movie. The riot, the crowds moving out of the buildings when the fire alarms went off, and the convention in Vegas. I don’t know exactly why, but I thought those were extremely well done.

The movie is about revenge, but its unexpected usage of revenge from both the viewpoint of Jason Bourne and “The Asset” is interesting. Its such a shame they abandoned it right at the end of the movie.

The original trilogy captured that impersonal sadness and futility of the whole situation whenever Bourne encounters an ‘asset’ and is forced to kill him. The asset has his orders and Bourne must defend himself, and someone has to die, that’s just the way the world works. It didn’t need any of these plot/character contrivances to be impactful.

It would have been good to revisit the scene where the Professor in Identity says:

The Professor: [the Professor’s dying words] Look at this. Look at what they make you give.


So what exactly are my issues with Jason Bourne?

Jason Bourne’s story was already pretty wrapped up in “The Bourne Ultimatum” (2007). So I wasn’t sure why he was returning, or why the beats of the movie felt like the best bits of other movies put together.

The movie starts in a scene that kept me thinking of the start of “Rambo III”. Both Rambo and Bourne are in an underground fight scene, living off the grid. I wasn’t sure what those fight scenes had to do with the movie; other than show that Bourne doesn’t like living with his past

The social media platform sub-plot really grinds the movie, almost to a halt. Any time it’s mentioned or brought up, the movie slows down and I feel it’s just in there to score political points for the filmmakers.

Yes, we get it. Social media platforms, like Facebook, are in bed with the CIA and other alphabet soup government agencies. It adds pretty much nothing to the movie. It seems to go nowhere, except to stage the final scene.

I believe the whole social media platform sub-plot could have been gutted and still have the final scene, perhaps with some small changes.

Nicky Parson’s death is a throw-away scene and Bourne looked like he didn’t give two sh*ts about it, he just basically moved on.

It would have been good to have added Parson’s death to mean something to Jason; perhaps a few scenes where he blames himself for her death, and even reflect it in Heather Lee (played by Alicia Vikander) who could be in a similar situation and then Bourne redeem’s himself.

Talking of Alicia Vikander, I found her accent to be all over the place; she played her character very well, an ambitious career-first person who uses people to position herself further up the chain, much to the disdain for her colleagues.

Tommy Lee Jones didn’t really do much, he looked very weathered and old. But I did like him as an act, he didn’t seem to do much except twirl his moustache.

Beyond actors, I felt the movie has too many coincidences and hack-eyed attempts to loop everything together.

The coincidence that The Asset and Jason Bourne are tied together are just eye-rolling and lazy, especially how the Asset is the guy who killed Bourne’s father.

It’s just coincidence that the guy who’s chasing Bourne in the present was also the guy who killed his father and he has a reason to be pissed at Bourne now, making it a personal vendetta?

The coincidence that nearly every CCTV camera is hooked up to the Internet, and shared with the CIA

The coincidence that the CIA makes a decision that always works; such as pulling the plug on the power to hacking station kills everything, it’s not like they were on laptops, oh wait.

The coincidence of people from being spotted in a huge crowd with relative ease to having all the spy gadgets (crucial to the plot) being within arms reach at a convention, etc etc.

There was also small things like: The movie has a privacy stance; its against breaking privacy, except at the end when the movie breaches a character’s privacy? What was all that about?

One last thing I didn’t like at all and I feel I need to mention it.

The end fight scene between Jason Bourne and The Asset is filmed: in the dark, at night, in a sewer with full-on shaky camera. You don’t see ANYTHING. The 12A rating may have been part reason for the bad end fight.

The hits mean nothing, and have no power. The Asset is a constant threat in the movie, yet at the end; the fight is a meaningless mess that is ended within 5 minutes. WHAT A WASTE OF TIME!

Can Paul Greengrass not film fights? Seriously, just centre the fight on camera; position it stationary and ensure the actors’ faces are clear. Make all cuts clean, and keep the focus on the fight. Its pretty easy.

I really went into the cinema hoping that Greengrass and Hollywood would have learnt something from The Raid, and other action movies from the East, yet they make the same mistakes and you don’t see anything; it was really bad and made me really quite angry.

Things that should have not been in the movie:

  • “Enhance!”, Heather Lee barking orders to zoom on a still image.
  • “Use sql to corrupt their database”
  • Mr Social Media CEO getting a standing ovation for saying the platform had great privacy settings? I’ve never seen a tech crowd that excited about anything, particularly privacy.

So in summary.

“Jason Bourne” (2016) is a summer chase-action movie that rekindles some of the nostalgic memories of the prior movies, but certain elements such as poor fight filmography, poor character exposition and lazy coincidence scenes really brought this movie far below its predecessors.

It’s smarter-than-average action film that isn’t as good as its predecessors.

Rating: 6/10

Worth watching. But don’t expect anything special.

Links:

Scarface PS2 – Retrospective review

Recently I’ve been re-playing the 2006 Playstation 2 game Scarface, to 100% completion. It took me approximately less than 2 days to do.

I had a blast, but there are things wrong with the game that I hadn’t noticed when I first played the game.

It may seem odd to replay a game that is 10 years old (as of 2016) and even then get the criticism that “why don’t you just play GTA, its a better game“; yes it is, but purely for an arcade-style action fun; I don’t think you can beat Scarface on PS2, even with its low resolution graphics.

Whilst the opinion that its yet another GTA clone is often quoted, I feel it does offer a little more fun, a more arcade-style approach that the later titles of the GTA line of games didn’t seem to offer.

It didn’t have as nearly as many side quests as the pinnacle of open world games, GTA San Andreas; and it didn’t have the same allure as GTA Vice City; which is heavily inspired from the 1980s Scarface movie.

But at the same time, this game has its charm; and mostly fun.

So, what exactly is wrong with the game?

Issue: It loses the message of the movie

The message of the movie is that there’s no going back from the life of crime.

The idea of the movie is that Tony gets his comeuppance; that he dies alone in a self-destructive spiral of cocaine addiction, paranoia and desire for wealth beyond anything else, even at the loss of those he trusted.

It was supposed also be some sort of ironic message that the only time Montana did something based on actual morals, it was the thing that actually killed him

The message is kind of destroyed when you put a spin that Tony got away just to do every single shitty decision again.

Beyond “losing the message of the movie”, there are other smaller issues I found with the game.

Issue: The end boss (Sosa) is way too easy to kill

It would have been fun to have Sosa at least a bit harder to kill; perhaps put him in a tank or he keeps running away with relentless hordes coming for you whilst he’s trying to escape in a helicopter?

Issue: Set pieces are never used thoroughly

There is only one mission, except the side-mission Felix leads, where Tony has to deliver goods by a Van. I would have liked it if he had to do more deliveries to get his initial reputation up without buying hard assets.

I only remember one or two missions with helicopters being your main boss or sub-boss.  There should have been more of them.

There is a ship cargo tanker on the Miami map in the Industrial zone, but you never go there to collect any formal cargo.  I would have preferred it if there is deliveries of product via the ship cargo at set intervals; that way a player doesn’t have to go to the Islands all the time.

Issue: The game relies too heavily on pick up and deliver

There is a lot of missions, side-quests where you are simply picking up something to deliver it elsewhere.  I think 90% of the game is pick up and deliver; the worst ones are the distribution missions.  Sure its fun to rack up the many millions of dollars you get for delivering product to your fronts; but doing it like 10-20 times gets relentlessly repetitive and boring.

To speed things up a bit you could just focus relentlessly on getting all 4 storehouses and then focus on getting the “Harvest plantation” as fast as possible; this means you reduce the shipping part, but you still have to deliver it.

Improvement: Have distributors or trucks on call that deliver your product; but it comes at a risk that you’ll lose the product to police/gangs and it comes with a percentage cut of delivery revenue.

Issue: Hitting 100%; but nothing to do

Hitting 100% in Scarface is pretty easy. Once you’ve beaten the story, bought every Exotic, eliminated every rival gang, there is nothing to do.

Other than doing yet more distribution deals, the only thing I can think of is to go to the Islands with your personal female bodyguards (whom you unlock once you get 100%) and just start wars with the many spawning enemies of the islands.

So what could they have done?

  1. Tony loses the fronts – to the Columbians; Make it a two-part story (200%)., and the second part is the Columbians take over Miami who are twice as strong, their armies twice as strong; make it a real challenge.  The last mission could be revisiting the Plantation, or Islands to take out the Columbians one final time.
  2. The Sandman twist – When I originally played the game, I thought that the Sandman character was going to turn on you; he never did.  It would have been better if he did and then this would reinforced the hate relationship between Sosa and Sandman.  Sandman’s motive: He wants Sosa out the way to control 100% of everything and Tony was just the triggerman.  So first-part, Tony kills Sosa; second-part its Tony vs Sandman/Columbians who are twice as hard to kill.
  3. The islands become un-lockable to control.  Missions on the islands become unlocked so now you try to take over the islands with their turf, with the final mission being in Boliva or some other island (not on the maps).
  4. Unlock Survivor mode or Relentless mode – Where you just have to live as long as possible
  5. Unlock other (abstracted) cities. A way to make distribution less boring would be if you could decide to attempt to send product to them.
  6. Other side-missions that are not simply pick-up and deliver

Despite all this, the game is actually a lot of fun, despite it being quite short and nothing to do when you hit 100%, I did forget how fun the game was; I enjoyed it for what it was.

Its just a shame there isn’t much to it.

A look at UK Games Expo 2016

uk games expo

Now in its 10th year, the world famous UK Games Expo is the biggest hobby games convention in the UK, showcasing various thousands of card, board, role-playing, miniature, and family games games under one roof.

With over 170 exhibitors, publishers, retailers, independent designers and artists; the event is set to the be the largest yet.

Aimed squarely at families, the general public and the enthusiast alike; the UK Games Expo is an accessible, family-friendly annual event held at the NEC Hilton Metropole, Birmingham (just next to Birmingham International Airport/Railway station) and aims to be the peak event where all aspects of the growing tabletop hobby are represented.

Having attended 3 prior events, I can safely say that the event is a fun, friendly atmosphere; easily accessible and open to the general public. Wandering around trade stands, trying out new and old games alike is a fantastic experience.

Usually held over 3 days, the event offers a range of tournaments and championships for popular games, like Ticket to Ride and the chance to play the newest released games.

There is also a large bring and buy trade fair, which attracts many enthusiasts and offers a great chance to grab a bargain, or that rare game you’ve been after.

In addition, the playtest area is a great area; upcoming designers bring their latest creations and get the general public to play them. It’s great to see so many designs that are coming through and shows that anybody with a great idea, that is willing to put in the time to refine it can make it.

One of the great appeals of the UK Games Expo is that it is open to the public, you can book in advance or purchase tickets on the day.

Just look out for the Game Ambassadors in blue shirts – if you are new, on your own or just lost ask them and they will help.

For more information, or to book tickets visit:

http://www.ukgamesexpo.co.uk/

What cables do you need to develop for Apple TV 4th generation?

Having recently bought an Apple TV 4th generation for development purposes, I thought it might be useful for other developers who wish to dabble with the system to know what cables are needed to deploy your apps from XCode to the actual device.

Notably the Apple TV (4th Gen) doesn’t actually come with the cable needed to connect from your machine to the device; it does come with a cable, but this is only for charging the remote.

Instead, you will need a USB male to male cable (I think it was USB 3.0, but don’t quote me on that); in addition you will need a “USB-C to USB-A convertor” cable. You can purchase this from Apple.

As with all other XCode projects; in order to deploy you will need to get a deployment provisioning profile via the Apple development website.

My first thought was that it wasn’t going to work; Apple is quite harsh on deploying apps onto devices that are not Apple-branded cables; but was pleasantly surprised to see it working.

So in short; you will need:

  • 1x USB to USB (male to male) cable
  • 1x USB-C to USB-A converter cable

I hope this helps.

My recommended economic boardgames

So, you’re thinking of buying a board game perhaps for a spouse, a friend or family. The typical go to point is Monopoly.

I don’t really like Monopoly. It was invented last century. Let that sink in for a while. A whole century!

Its decisions are also sterile; you really don’t get to make any — its all dependent upon a roll and move mechanic that is pretty archaic.

Further, everyone plays the rules wrong. There is no free parking money pot, properties are bought from the get-go; and auctions/trading are meant to be encouraged.

The biggest problem I have is, it takes forever and I don’t feel like its fun or engaging or rewarding to play.

Since then there has been a revolution in board games from Germany and elsewhere typically called Euro Games; these games are more fun, typically don’t have player elimination, everyone is involved and strategy/well-laid out plans are rewarded.

I’ve heard from someone that board games ruins the entrepreneurial spirit. I disagree. If you have the right kind of game, one that is rewards strategy, and reduces luck and promotes core skills like maths, social connectivity and can be fun.

Having played a number of euro board games over the past 3-4 years here’s a few games I would recommend (In no particular order).

Acquire

Yes; it was invented last century and can be quite dry and abstract; but it beats Monopoly any day of the week.
Its a stock holding game, where you invest or expand hotels that can merge with other hotels and reap dividends to those who have invested in to them.

The game is perfect for those tech startups whom are looking to be “acquired”; as it perfectly reiterates the mantra of building a small company, build its value and sell it!

I would recommend the 1990 version; not the crappy current cardboard version. Or the earlier 1960/1970 versions as these have a unique look.

Link: Acquire (Amazon)

Mombasa

Currently my favorite game right now. Players are investors in Colonial Africa; but don’t let the theme scare you, its actually got a few really good mechanics – one of which is the way it uses cards into discard piles.

Its a stock holding game, where you are trying to push up the price of the various companies you have invested in, but also offers other routes including moving up a diamond track and creative book-keeping; both of which give you points (cash) at the end of the game.

Highly recommended

Link: Mombasa (Amazon)

Power Grid

Become a “Monty Burns” industrialist building power plant factories on the map representing various locations such as Germany or the United States (other expansion maps do exist) where you need finances to win power plants at an auction, then buy its raw materials (such as nuclear, coal and oil) in a very interesting supply and demand system — where goods can be cheaper if they are plentiful, or alternatively can be more expensive the higher the good costs are.

Its not a race for money (although that certainly helps), but a race to build a number of power plants that can successfully power a number of cities.

Link: Power Grid (Amazon)

Panamax

Players operate ships laden with goods through the famous Panama canal from one side to the other, timing their movements carefully and ensuring that they do not leave their goods in the warehouse or leave the ship in areas with big taxes. Timed movements can push out other ships.

It also has a simplified 1 dimensional stock market, and players can invest in rival player’s companies.

In addition, players can add their goods onto rival goods. The reason you’d do this is because if you are invested in the company it can pay off for you too as its value goes up.

Link: Panamax (Amazon)

All these games are a good start for economic board games.

NSPredicates – SUBQuery on a parent-child relationship

I am currently working on a game where there is a parent-child relationship in a quite small array where;

A `Group` (parent)
has many `Child` objects
where 1 `Child` object can be owned by only 1 `Player`
and a `Player` can only ever own 1 `Child` per group

In the game, a `Child` object is called `Locomotive` (the game is about selling Locomotives) and a given `Player` can own a single locomotive in a given group.

I needed a way to grab all the child objects in a given array that met a series of conditions; in short, I’m after a list of child objects that I can `legally` purchase.

By `legally` I mean from the following rules (in no particular order)

  • I want to remove all children where I do not own anything
  • I want to remove all children which I already own a locomotive
  • I want to remove all children where I don’t have enough money to buy it
  • I want to remove all children by inspecting the group to only show those children where the sum total of orders > 0
  • I want to remove all children where something has been bought already

Phew, quite a lot of conditions. At first I was not sure how to solve so many conditions.

My first solution was to use a NSPredicate… with a block statement and simply loop through everything.

Code:
    NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
        EngYard_LocomotiveGroup *group = evaluatedObject;
        for (EngYard_Locomotive *child in group.locomotives) {
            if ( ([child.purchased boolValue] == NO) && (child.owner != player) && (group.purchasePrice < player.cash) && (group.initialOrders>0 || [group.totalOrders integerValue]>0 || group.unlocked==YES) )
            {
                return YES;
                break;
            }
            return NO;
            break;
        }
        return NO;
    }];

This seemed quite a lot of code. Surely there is an easier way to do this?

SUBQUERY to the rescue!

Having played around with the SUBQUERY for a while, I finally got a single-line solution;

Code:
    
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(locomotives, $rv, $rv.purchased = %@).@count > 0 AND (purchasePrice < %d) AND (initialOrders>0 OR orders.@sum.integerValue>0 OR unlocked==YES)", @NO, player.cash];

I double checked both instances in my logger; and they both return my expected results.

Now on to more complex matters — how to make the AI make a decision to buy.