Image copyright Reuters Image caption President Rodrigo Duterte (centre) has spoken of a turning point in relations with China

What has happened to the swashbuckling presidential candidate who six months ago said he would personally retake the Spratly Islands from China, riding out to sea on a jet ski to plant the Philippine flag on a disputed shoal? And what has happened to the foulmouthed commander-in-chief of a key US ally who only last month casually called his American counterpart a "son of a whore"?

Ahead of this week's state visit to China, President Rodrigo Duterte of the Philippines has washed out his mouth and prepared a new set of lines. He has talked of a key turning point in relations with China, promised to speak softly and praised China's "good, sound policies, internal and external".

Abandoning his jet ski threats, he told China's state news agency Xinhua: "There is no sense in going to war. There is no sense fighting over a body of water... We want to talk about friendship, we want to talk about co-operation, and most of all, we want to talk about business. War would lead us nowhere."

This shift to conciliator-in-chief is all the more striking in the context of a relationship between the two countries which seemed to have reached rock bottom only three months ago, when the Philippines won a massive legal victory against China's claims in the South China Sea, inflicting great damage in the process on China's reputation as a rising power willing to respect international law.

So why has the notoriously candid Filipino president suddenly decided that now, when it comes to China, discretion is the better part of valour?

It all comes down to a calculation about money. With mangoes thrown in. And a lucky moment.

Image copyright AFP Image caption Beijing has frozen the Philippines out of the benefits of Chinese wealth for four years

The simple fact is that a clear-cut courtroom win against China, coming just after Mr Duterte took up office, has created opportunities for a new approach. China cannot take that legal victory away. And meanwhile in the nearly four years since the Philippines began its legal case, it has suffered economically as Beijing has frozen Manila out of the benefits of Chinese wealth. China has actively discouraged tourists, investors and importers from looking to the Philippines. With the legal card in his back pocket, Mr Duterte wants that economic chill to end. He sees no reason why the Philippines shouldn't, just like most other countries in the region, have its cake and eat it - enjoy the economic benefits of China's growth at the same time as sheltering under the US security umbrella.

In fact, given the four-year lag, and the bargaining power that comes from being the David who saw off the mighty Chinese Goliath in court, Mr Duterte has calculated that there is pent up potential to exploit. So this week he is visiting China with a business delegation several hundred strong, and when he meets President Xi Jinping on Thursday, the two leaders will preside over the signing of deals in energy, infrastructure and tourism.

And there's even tropical fruit among the low-hanging fruit for Mr Duterte to pick. Beijing has promised to increase imports of bananas, pineapples and mangoes and, crucially, to lift a travel advisory warning Chinese tourists not to visit the Philippines. The Chinese ambassador to the Philippines, Zhao Jianhua, has said the Philippines can expect up to a million Chinese tourists by the end of next year, bringing in revenue of $1bn. What's more, China has promised to support Mr Duterte's controversial battle against illegal drugs traffickers, and he will tour Chinese law enforcement and rehabilitation facilities during his visit.

Tactical victory

So where does this leave the hard-won argument over the Scarborough Shoal?

In Mr Duterte's mind, it leaves it no worse or better off than it was before: that is, with a Philippine legal victory and Chinese possession. He calculates that he can win financial carrots in China for every day he refrains from flourishing the legal card, and what's more, playing that card now would serve no material purpose as an Obama presidency in its final days is in no position to enforce it.

Mr Duterte is even angling for a tactical victory on the Scarborough Shoal as reward for his diplomatic restraint. He gambles that if he goes to China and abstains from rallying the region, the US and the international community behind Manila's legal case, he gives China a chance to make good its argument that Asian diplomacy without the involvement of the US can be a "win-win" for rivals in the South China Sea. So Mr Duterte has said that during this week's visit, he will press the cause of Filipino fishermen who have been denied access to waters around Scarborough Shoal by China's coastguard. And Beijing has said in turn that the Chinese side is very much interested in fishery co-operation.

Image copyright Reuters Image caption President Xi Jingping (right) will meet Mr Duterte on Thursday

In the short term, the region will be transfixed by Mr Duterte's striking new gamesmanship, but in the long run, there is far more at stake here than fishing, fruit exports and protestations of friendship. $5tn in global trade passes through the South China Sea every year, and to many observers the region's territorial disputes have become a proxy for a broader contest between the established American superpower and a rising China.

Mr Duterte himself has acknowledged that at some point tackling the issue with China becomes inevitable.

"We will not raise hell now… but there will come a time that we have to do some reckoning about this."

We may get a hint that the reckoning is coming when Mr Duterte stops declaring that he doesn't like Americans, stops querying the value of his country's alliance with the US and starts muttering about his jet ski again. But China will be ready for him. It is already playing the long game, hoping that this week's charm offensive will begin an embrace so seductive that it ultimately undermines the Philippines' pivotal role in upholding US power in the Pacific.

Gamesmanship is all very well, but this is a game for the very high rollers.